From 9897065c2198659140ebe0f661be0ce7dda5a95c Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 5 Aug 2008 13:09:44 +0000 Subject: 2008-08-05 Xudong Guan PR 1212/cpukit * rtems/src/taskmode.c, score/src/threadtickletimeslice.c: Time slicing will not happen if the task mode is changed from a non-timeslicing mode to timeslicing mode if it is done by the executing thread (e.g. in its task body). This change includes sp44 to demonstrate the problem and verify the correction. --- cpukit/ChangeLog | 9 +++++++++ cpukit/rtems/src/taskmode.c | 5 +++-- cpukit/score/src/threadtickletimeslice.c | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index c51061c338..018ac2da5d 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,12 @@ +2008-08-05 Xudong Guan + + PR 1212/cpukit + * rtems/src/taskmode.c, score/src/threadtickletimeslice.c: Time slicing + will not happen if the task mode is changed from a non-timeslicing + mode to timeslicing mode if it is done by the executing thread (e.g. + in its task body). This change includes sp44 to demonstrate the + problem and verify the correction. + 2008-08-04 Joel Sherrill PR 1265/cpukit diff --git a/cpukit/rtems/src/taskmode.c b/cpukit/rtems/src/taskmode.c index 4deccf4918..65fc07a81f 100644 --- a/cpukit/rtems/src/taskmode.c +++ b/cpukit/rtems/src/taskmode.c @@ -89,9 +89,10 @@ rtems_status_code rtems_task_mode( executing->is_preemptible = _Modes_Is_preempt(mode_set) ? TRUE : FALSE; if ( mask & RTEMS_TIMESLICE_MASK ) { - if ( _Modes_Is_timeslice(mode_set) ) + if ( _Modes_Is_timeslice(mode_set) ) { executing->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE; - else + executing->cpu_time_budget = _Thread_Ticks_per_timeslice; + } else executing->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE; } diff --git a/cpukit/score/src/threadtickletimeslice.c b/cpukit/score/src/threadtickletimeslice.c index 0666066b28..5e2d6f8ed5 100644 --- a/cpukit/score/src/threadtickletimeslice.c +++ b/cpukit/score/src/threadtickletimeslice.c @@ -76,7 +76,7 @@ void _Thread_Tickle_timeslice( void ) case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE: case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE: - if ( --executing->cpu_time_budget == 0 ) { + if ( (int)(--executing->cpu_time_budget) <= 0 ) { _Thread_Reset_timeslice(); executing->cpu_time_budget = _Thread_Ticks_per_timeslice; } -- cgit v1.2.3