diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-07-04 14:34:23 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-07-09 10:05:17 +0200 |
commit | 5c3d2509593476869e791111cd3d93cc1e840b3a (patch) | |
tree | 2f642fcce66748460f0f823fbeb6f292267b8cd0 /cpukit/score/src/schedulersimplesmp.c | |
parent | schedulerpriorityaffinitysmp.c: Add period at end of sentence (diff) | |
download | rtems-5c3d2509593476869e791111cd3d93cc1e840b3a.tar.bz2 |
score: Implement scheduler helping protocol
The following scheduler operations return a thread in need for help
- unblock,
- change priority, and
- yield.
A thread in need for help is a thread that encounters a scheduler state
change from scheduled to ready or a thread that cannot be scheduled in
an unblock operation. Such a thread can ask threads which depend on
resources owned by this thread for help.
Add a new ask for help scheduler operation. This operation is used by
_Scheduler_Ask_for_help() to help threads in need for help returned by
the operations mentioned above. This operation is also used by
_Scheduler_Thread_change_resource_root() in case the root of a resource
sub-tree changes. A use case is the ownership change of a resource.
In case it is not possible to schedule a thread in need for help, then
the corresponding scheduler node will be placed into the set of ready
scheduler nodes of the scheduler instance. Once a state change from
ready to scheduled happens for this scheduler node it may be used to
schedule the thread in need for help.
Diffstat (limited to 'cpukit/score/src/schedulersimplesmp.c')
-rw-r--r-- | cpukit/score/src/schedulersimplesmp.c | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/cpukit/score/src/schedulersimplesmp.c b/cpukit/score/src/schedulersimplesmp.c index ee540bebd0..084d78251f 100644 --- a/cpukit/score/src/schedulersimplesmp.c +++ b/cpukit/score/src/schedulersimplesmp.c @@ -47,7 +47,7 @@ void _Scheduler_simple_SMP_Node_initialize( Thread_Control *the_thread ) { - Scheduler_SMP_Node *node = _Scheduler_SMP_Thread_get_node( the_thread ); + Scheduler_SMP_Node *node = _Scheduler_SMP_Thread_get_own_node( the_thread ); _Scheduler_SMP_Node_initialize( node, the_thread ); } @@ -162,6 +162,28 @@ static void _Scheduler_simple_SMP_Extract_from_ready( _Chain_Extract_unprotected( &node_to_extract->Node ); } +static Thread_Control *_Scheduler_simple_SMP_Get_idle_thread( + Scheduler_Context *context +) +{ + return _Scheduler_SMP_Get_idle_thread( + context, + _Scheduler_simple_SMP_Extract_from_ready + ); +} + +static void _Scheduler_simple_SMP_Release_idle_thread( + Scheduler_Context *context, + Thread_Control *idle +) +{ + _Scheduler_SMP_Release_idle_thread( + context, + idle, + _Scheduler_simple_SMP_Insert_ready_fifo + ); +} + void _Scheduler_simple_SMP_Block( const Scheduler_Control *scheduler, Thread_Control *thread @@ -175,7 +197,8 @@ void _Scheduler_simple_SMP_Block( _Scheduler_simple_SMP_Extract_from_ready, _Scheduler_simple_SMP_Get_highest_ready, _Scheduler_simple_SMP_Move_from_ready_to_scheduled, - _Scheduler_SMP_Allocate_processor_lazy + _Scheduler_SMP_Allocate_processor_lazy, + _Scheduler_simple_SMP_Get_idle_thread ); } @@ -197,7 +220,8 @@ static Thread_Control *_Scheduler_simple_SMP_Enqueue_ordered( insert_scheduled, _Scheduler_simple_SMP_Move_from_scheduled_to_ready, _Scheduler_SMP_Get_lowest_scheduled, - _Scheduler_SMP_Allocate_processor_lazy + _Scheduler_SMP_Allocate_processor_lazy, + _Scheduler_simple_SMP_Release_idle_thread ); } @@ -245,11 +269,14 @@ static Thread_Control *_Scheduler_simple_SMP_Enqueue_scheduled_ordered( context, node, order, + _Scheduler_simple_SMP_Extract_from_ready, _Scheduler_simple_SMP_Get_highest_ready, insert_ready, insert_scheduled, _Scheduler_simple_SMP_Move_from_ready_to_scheduled, - _Scheduler_SMP_Allocate_processor_lazy + _Scheduler_SMP_Allocate_processor_lazy, + _Scheduler_simple_SMP_Get_idle_thread, + _Scheduler_simple_SMP_Release_idle_thread ); } @@ -291,7 +318,8 @@ Thread_Control *_Scheduler_simple_SMP_Unblock( return _Scheduler_SMP_Unblock( context, thread, - _Scheduler_simple_SMP_Enqueue_fifo + _Scheduler_simple_SMP_Enqueue_fifo, + _Scheduler_simple_SMP_Release_idle_thread ); } @@ -318,6 +346,23 @@ Thread_Control *_Scheduler_simple_SMP_Change_priority( ); } +Thread_Control *_Scheduler_simple_SMP_Ask_for_help( + const Scheduler_Control *scheduler, + Thread_Control *offers_help, + Thread_Control *needs_help +) +{ + Scheduler_Context *context = _Scheduler_Get_context( scheduler ); + + return _Scheduler_SMP_Ask_for_help( + context, + offers_help, + needs_help, + _Scheduler_simple_SMP_Enqueue_fifo, + _Scheduler_simple_SMP_Release_idle_thread + ); +} + Thread_Control *_Scheduler_simple_SMP_Yield( const Scheduler_Control *scheduler, Thread_Control *thread |