[Bug 1212] New: timeslice not working after task mode change
rtems-bugs at rtems.org
rtems-bugs at rtems.org
Fri Jan 12 10:52:55 UTC 2007
http://www.rtems.org/bugzilla/show_bug.cgi?id=1212
Summary: timeslice not working after task mode change
Product: RTEMS
Version: 4.6
Platform: All
OS/Version: RTEMS
Status: NEW
Severity: major
Priority: P3
Component: cpukit
AssignedTo: joel.sherrill at oarcorp.com
ReportedBy: xudong.guan at criticalsoftware.com
CC: xudong.guan at criticalsoftware.com
Time slicing will not happen if task mode is changed from a non-timeslicing
mode to the time slicing mode after it was started (i.e. by itself in its task
body).
An example that reproduces the bug is attached below.
Analysis: The cpu_time_budget field of the victim task is 0 after task creation
and is still 0 after task mode change to TIMESLICE. As a result,
_Thread_Tickle_timeslice() will cause an underflow of cpu_time_budget, which
practically disables timeslicing.
Patch #1 prevents this possible underflow. Patch #2 reset the cpu_time_budget
field after mode change.
Patch #1:
diff --git a/src/rtems/cpukit/score/src/threadtickletimeslice.c
b/src/rtems/cpukit/score/src/threadtickletimeslice.c
index 786f5c5..3d308bc 100644
--- a/src/rtems/cpukit/score/src/threadtickletimeslice.c
+++ b/src/rtems/cpukit/score/src/threadtickletimeslice.c
@@ -72,7 +72,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;
}
Patch #2:
diff --git a/src/rtems/cpukit/rtems/src/taskmode.c
b/src/rtems/cpukit/rtems/src/taskmode.c
index 142812e..77f3a03 100644
--- a/src/rtems/cpukit/rtems/src/taskmode.c
+++ b/src/rtems/cpukit/rtems/src/taskmode.c
@@ -85,9 +85,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;
}
--
Configure bugmail: http://www.rtems.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the bugs
mailing list