summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--c/src/exec/score/src/thread.c16
-rw-r--r--cpukit/score/src/thread.c16
2 files changed, 32 insertions, 0 deletions
diff --git a/c/src/exec/score/src/thread.c b/c/src/exec/score/src/thread.c
index 9060185348..8024b51dbf 100644
--- a/c/src/exec/score/src/thread.c
+++ b/c/src/exec/score/src/thread.c
@@ -518,6 +518,7 @@ boolean _Thread_Initialize(
the_thread->resource_count = 0;
the_thread->real_priority = priority;
the_thread->Start.initial_priority = priority;
+ the_thread->ticks_executed = 0;
_Thread_Set_priority( the_thread, priority );
@@ -945,12 +946,27 @@ void _Thread_Tickle_timeslice( void )
executing = _Thread_Executing;
+ /*
+ * Increment the number of ticks this thread has been executing
+ */
+
+ executing->ticks_executed++;
+
+ /*
+ * If the thread is not preemptible or is not ready, then
+ * just return.
+ */
+
if ( !executing->is_preemptible )
return;
if ( !_States_Is_ready( executing->current_state ) )
return;
+ /*
+ * The cpu budget algorithm determines what happens next.
+ */
+
switch ( executing->budget_algorithm ) {
case THREAD_CPU_BUDGET_ALGORITHM_NONE:
break;
diff --git a/cpukit/score/src/thread.c b/cpukit/score/src/thread.c
index 9060185348..8024b51dbf 100644
--- a/cpukit/score/src/thread.c
+++ b/cpukit/score/src/thread.c
@@ -518,6 +518,7 @@ boolean _Thread_Initialize(
the_thread->resource_count = 0;
the_thread->real_priority = priority;
the_thread->Start.initial_priority = priority;
+ the_thread->ticks_executed = 0;
_Thread_Set_priority( the_thread, priority );
@@ -945,12 +946,27 @@ void _Thread_Tickle_timeslice( void )
executing = _Thread_Executing;
+ /*
+ * Increment the number of ticks this thread has been executing
+ */
+
+ executing->ticks_executed++;
+
+ /*
+ * If the thread is not preemptible or is not ready, then
+ * just return.
+ */
+
if ( !executing->is_preemptible )
return;
if ( !_States_Is_ready( executing->current_state ) )
return;
+ /*
+ * The cpu budget algorithm determines what happens next.
+ */
+
switch ( executing->budget_algorithm ) {
case THREAD_CPU_BUDGET_ALGORITHM_NONE:
break;