summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-07-10 14:27:42 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-07-10 15:29:57 +0200
commit27783f6ca8683eaf4826e777963c32a63f55da31 (patch)
tree45a3294eb7cfd6bae51e1cb1661f699b0e23d6e8 /cpukit
parentscore: Fix assertions (diff)
downloadrtems-27783f6ca8683eaf4826e777963c32a63f55da31.tar.bz2
score: Fix scheduler helping implementation
Do not extract the idle threads from the ready set so that there is always a thread available for comparison.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/score/include/rtems/score/schedulerprioritysmpimpl.h22
-rw-r--r--cpukit/score/include/rtems/score/schedulersmp.h4
-rw-r--r--cpukit/score/include/rtems/score/schedulersmpimpl.h59
-rw-r--r--cpukit/score/src/schedulerpriorityaffinitysmp.c19
-rw-r--r--cpukit/score/src/schedulerprioritysmp.c16
-rw-r--r--cpukit/score/src/schedulersimplesmp.c38
6 files changed, 39 insertions, 119 deletions
diff --git a/cpukit/score/include/rtems/score/schedulerprioritysmpimpl.h b/cpukit/score/include/rtems/score/schedulerprioritysmpimpl.h
index bb200b4641..9ae01038b6 100644
--- a/cpukit/score/include/rtems/score/schedulerprioritysmpimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerprioritysmpimpl.h
@@ -148,28 +148,6 @@ static inline void _Scheduler_priority_SMP_Extract_from_ready(
);
}
-static inline Thread_Control *_Scheduler_priority_SMP_Get_idle_thread(
- Scheduler_Context *context
-)
-{
- return _Scheduler_SMP_Get_idle_thread(
- context,
- _Scheduler_priority_SMP_Extract_from_ready
- );
-}
-
-static void _Scheduler_priority_SMP_Release_idle_thread(
- Scheduler_Context *context,
- Thread_Control *idle
-)
-{
- _Scheduler_SMP_Release_idle_thread(
- context,
- idle,
- _Scheduler_priority_SMP_Insert_ready_fifo
- );
-}
-
static inline void _Scheduler_priority_SMP_Do_update(
Scheduler_Context *context,
Scheduler_Node *node_to_update,
diff --git a/cpukit/score/include/rtems/score/schedulersmp.h b/cpukit/score/include/rtems/score/schedulersmp.h
index a58417a268..9e11488584 100644
--- a/cpukit/score/include/rtems/score/schedulersmp.h
+++ b/cpukit/score/include/rtems/score/schedulersmp.h
@@ -54,6 +54,10 @@ typedef struct {
/**
* @brief Chain of the available idle threads.
+ *
+ * Idle threads are used for the scheduler helping protocol. It is crucial
+ * that the idle threads preserve their relative order. This is the case for
+ * this priority based scheduler.
*/
Chain_Control Idle_threads;
} Scheduler_SMP_Context;
diff --git a/cpukit/score/include/rtems/score/schedulersmpimpl.h b/cpukit/score/include/rtems/score/schedulersmpimpl.h
index a4890df4d0..156307db24 100644
--- a/cpukit/score/include/rtems/score/schedulersmpimpl.h
+++ b/cpukit/score/include/rtems/score/schedulersmpimpl.h
@@ -425,16 +425,12 @@ static inline bool _Scheduler_SMP_Is_processor_owned_by_us(
}
static inline Thread_Control *_Scheduler_SMP_Get_idle_thread(
- Scheduler_Context *context,
- Scheduler_SMP_Extract extract_from_ready
+ Scheduler_Context *context
)
{
Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context );
Thread_Control *idle = (Thread_Control *)
_Chain_Get_first_unprotected( &self->Idle_threads );
- Scheduler_Node *own_node = _Scheduler_Thread_get_own_node( idle );
-
- ( *extract_from_ready )( &self->Base, own_node );
_Assert( &idle->Object.Node != _Chain_Tail( &self->Idle_threads ) );
@@ -442,16 +438,13 @@ static inline Thread_Control *_Scheduler_SMP_Get_idle_thread(
}
static inline void _Scheduler_SMP_Release_idle_thread(
- Scheduler_Context *context,
- Thread_Control *idle,
- Scheduler_SMP_Insert insert_ready
+ Scheduler_Context *context,
+ Thread_Control *idle
)
{
Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context );
- Scheduler_Node *own_node = _Scheduler_Thread_get_own_node( idle );
_Chain_Prepend_unprotected( &self->Idle_threads, &idle->Object.Node );
- ( *insert_ready )( context, own_node );
}
static inline void _Scheduler_SMP_Allocate_processor_lazy(
@@ -536,8 +529,7 @@ static inline Thread_Control *_Scheduler_SMP_Enqueue_to_scheduled(
Scheduler_Node *lowest_scheduled,
Scheduler_SMP_Insert insert_scheduled,
Scheduler_SMP_Move move_from_scheduled_to_ready,
- Scheduler_SMP_Allocate_processor allocate_processor,
- Scheduler_Release_idle_thread release_idle_thread
+ Scheduler_SMP_Allocate_processor allocate_processor
)
{
Thread_Control *user = _Scheduler_Node_get_user( node );
@@ -570,7 +562,7 @@ static inline Thread_Control *_Scheduler_SMP_Enqueue_to_scheduled(
idle = _Scheduler_Release_idle_thread(
context,
lowest_scheduled,
- release_idle_thread
+ _Scheduler_SMP_Release_idle_thread
);
if ( idle == NULL ) {
needs_help = lowest_scheduled_user;
@@ -603,7 +595,6 @@ static inline Thread_Control *_Scheduler_SMP_Enqueue_to_scheduled(
* if this pointer is passed as the second argument to the order function.
* @param[in] allocate_processor Function to allocate a processor to a node
* based on the rules of the scheduler.
- * @param[in] release_idle_thread Function to release an idle thread.
*/
static inline Thread_Control *_Scheduler_SMP_Enqueue_ordered(
Scheduler_Context *context,
@@ -614,8 +605,7 @@ static inline Thread_Control *_Scheduler_SMP_Enqueue_ordered(
Scheduler_SMP_Insert insert_scheduled,
Scheduler_SMP_Move move_from_scheduled_to_ready,
Scheduler_SMP_Get_lowest_scheduled get_lowest_scheduled,
- Scheduler_SMP_Allocate_processor allocate_processor,
- Scheduler_Release_idle_thread release_idle_thread
+ Scheduler_SMP_Allocate_processor allocate_processor
)
{
Scheduler_Node *lowest_scheduled =
@@ -628,8 +618,7 @@ static inline Thread_Control *_Scheduler_SMP_Enqueue_ordered(
lowest_scheduled,
insert_scheduled,
move_from_scheduled_to_ready,
- allocate_processor,
- release_idle_thread
+ allocate_processor
);
} else {
( *insert_ready )( context, node );
@@ -656,8 +645,6 @@ static inline Thread_Control *_Scheduler_SMP_Enqueue_ordered(
* of ready nodes to the set of scheduled nodes.
* @param[in] allocate_processor Function to allocate a processor to a node
* based on the rules of the scheduler.
- * @param[in] get_idle_thread Function to get an idle thread.
- * @param[in] release_idle_thread Function to release an idle thread.
*/
static inline Thread_Control *_Scheduler_SMP_Enqueue_scheduled_ordered(
Scheduler_Context *context,
@@ -668,9 +655,7 @@ static inline Thread_Control *_Scheduler_SMP_Enqueue_scheduled_ordered(
Scheduler_SMP_Insert insert_ready,
Scheduler_SMP_Insert insert_scheduled,
Scheduler_SMP_Move move_from_ready_to_scheduled,
- Scheduler_SMP_Allocate_processor allocate_processor,
- Scheduler_Get_idle_thread get_idle_thread,
- Scheduler_Release_idle_thread release_idle_thread
+ Scheduler_SMP_Allocate_processor allocate_processor
)
{
Thread_Control *needs_help;
@@ -692,7 +677,7 @@ static inline Thread_Control *_Scheduler_SMP_Enqueue_scheduled_ordered(
_Scheduler_Try_to_schedule_node(
context,
highest_ready,
- get_idle_thread
+ _Scheduler_SMP_Get_idle_thread
)
) {
Thread_Control *user = _Scheduler_Node_get_user( node );
@@ -717,7 +702,7 @@ static inline Thread_Control *_Scheduler_SMP_Enqueue_scheduled_ordered(
idle = _Scheduler_Release_idle_thread(
context,
node,
- release_idle_thread
+ _Scheduler_SMP_Release_idle_thread
);
if ( idle == NULL ) {
needs_help = user;
@@ -752,8 +737,7 @@ static inline void _Scheduler_SMP_Schedule_highest_ready(
Scheduler_SMP_Extract extract_from_ready,
Scheduler_SMP_Get_highest_ready get_highest_ready,
Scheduler_SMP_Move move_from_ready_to_scheduled,
- Scheduler_SMP_Allocate_processor allocate_processor,
- Scheduler_Get_idle_thread get_idle_thread
+ Scheduler_SMP_Allocate_processor allocate_processor
)
{
while ( true ) {
@@ -763,7 +747,7 @@ static inline void _Scheduler_SMP_Schedule_highest_ready(
_Scheduler_Try_to_schedule_node(
context,
highest_ready,
- get_idle_thread
+ _Scheduler_SMP_Get_idle_thread
)
) {
_Scheduler_SMP_Allocate_processor(
@@ -797,7 +781,6 @@ static inline void _Scheduler_SMP_Schedule_highest_ready(
* @param[in] get_highest_ready Function to get the highest ready node.
* @param[in] move_from_ready_to_scheduled Function to move a node from the set
* of ready nodes to the set of scheduled nodes.
- * @param[in] get_idle_thread Function to get an idle thread.
*/
static inline void _Scheduler_SMP_Block(
Scheduler_Context *context,
@@ -805,8 +788,7 @@ static inline void _Scheduler_SMP_Block(
Scheduler_SMP_Extract extract_from_ready,
Scheduler_SMP_Get_highest_ready get_highest_ready,
Scheduler_SMP_Move move_from_ready_to_scheduled,
- Scheduler_SMP_Allocate_processor allocate_processor,
- Scheduler_Get_idle_thread get_idle_thread
+ Scheduler_SMP_Allocate_processor allocate_processor
)
{
Scheduler_SMP_Node *node = _Scheduler_SMP_Thread_get_node( thread );
@@ -815,7 +797,7 @@ static inline void _Scheduler_SMP_Block(
context,
&node->Base,
is_scheduled,
- get_idle_thread
+ _Scheduler_SMP_Get_idle_thread
);
if ( block ) {
@@ -830,8 +812,7 @@ static inline void _Scheduler_SMP_Block(
extract_from_ready,
get_highest_ready,
move_from_ready_to_scheduled,
- allocate_processor,
- get_idle_thread
+ allocate_processor
);
} else {
( *extract_from_ready )( context, &node->Base );
@@ -842,8 +823,7 @@ static inline void _Scheduler_SMP_Block(
static inline Thread_Control *_Scheduler_SMP_Unblock(
Scheduler_Context *context,
Thread_Control *thread,
- Scheduler_SMP_Enqueue enqueue_fifo,
- Scheduler_Release_idle_thread release_idle_thread
+ Scheduler_SMP_Enqueue enqueue_fifo
)
{
Scheduler_SMP_Node *node = _Scheduler_SMP_Thread_get_node( thread );
@@ -853,7 +833,7 @@ static inline Thread_Control *_Scheduler_SMP_Unblock(
thread,
&node->Base,
is_scheduled,
- release_idle_thread
+ _Scheduler_SMP_Release_idle_thread
);
Thread_Control *needs_help;
@@ -917,8 +897,7 @@ static inline Thread_Control *_Scheduler_SMP_Ask_for_help(
Scheduler_Context *context,
Thread_Control *offers_help,
Thread_Control *needs_help,
- Scheduler_SMP_Enqueue enqueue_fifo,
- Scheduler_Release_idle_thread release_idle_thread
+ Scheduler_SMP_Enqueue enqueue_fifo
)
{
Scheduler_SMP_Node *node = _Scheduler_SMP_Thread_get_own_node( offers_help );
@@ -940,7 +919,7 @@ static inline Thread_Control *_Scheduler_SMP_Ask_for_help(
offers_help,
needs_help,
previous_accepts_help,
- release_idle_thread
+ _Scheduler_SMP_Release_idle_thread
);
break;
case SCHEDULER_SMP_NODE_BLOCKED:
diff --git a/cpukit/score/src/schedulerpriorityaffinitysmp.c b/cpukit/score/src/schedulerpriorityaffinitysmp.c
index 39a0a481ea..41e44a0834 100644
--- a/cpukit/score/src/schedulerpriorityaffinitysmp.c
+++ b/cpukit/score/src/schedulerpriorityaffinitysmp.c
@@ -231,8 +231,7 @@ void _Scheduler_priority_affinity_SMP_Block(
_Scheduler_priority_SMP_Extract_from_ready,
_Scheduler_priority_affinity_SMP_Get_highest_ready,
_Scheduler_priority_SMP_Move_from_ready_to_scheduled,
- _Scheduler_SMP_Allocate_processor_exact,
- _Scheduler_priority_SMP_Get_idle_thread
+ _Scheduler_SMP_Allocate_processor_exact
);
/*
@@ -314,8 +313,7 @@ static Thread_Control *_Scheduler_priority_affinity_SMP_Enqueue_fifo(
_Scheduler_SMP_Insert_scheduled_fifo,
_Scheduler_priority_SMP_Move_from_scheduled_to_ready,
_Scheduler_priority_affinity_SMP_Get_lowest_scheduled,
- _Scheduler_SMP_Allocate_processor_exact,
- _Scheduler_priority_SMP_Release_idle_thread
+ _Scheduler_SMP_Allocate_processor_exact
);
}
@@ -399,8 +397,7 @@ Thread_Control *_Scheduler_priority_affinity_SMP_Unblock(
needs_help = _Scheduler_SMP_Unblock(
context,
thread,
- _Scheduler_priority_affinity_SMP_Enqueue_fifo,
- _Scheduler_priority_SMP_Release_idle_thread
+ _Scheduler_priority_affinity_SMP_Enqueue_fifo
);
/*
@@ -433,8 +430,7 @@ static Thread_Control *_Scheduler_priority_affinity_SMP_Enqueue_ordered(
insert_scheduled,
_Scheduler_priority_SMP_Move_from_scheduled_to_ready,
_Scheduler_priority_affinity_SMP_Get_lowest_scheduled,
- _Scheduler_SMP_Allocate_processor_exact,
- _Scheduler_priority_SMP_Release_idle_thread
+ _Scheduler_SMP_Allocate_processor_exact
);
}
@@ -482,9 +478,7 @@ _Scheduler_priority_affinity_SMP_Enqueue_scheduled_ordered(
insert_ready,
insert_scheduled,
_Scheduler_priority_SMP_Move_from_ready_to_scheduled,
- _Scheduler_SMP_Allocate_processor_exact,
- _Scheduler_priority_SMP_Get_idle_thread,
- _Scheduler_priority_SMP_Release_idle_thread
+ _Scheduler_SMP_Allocate_processor_exact
);
}
@@ -572,8 +566,7 @@ Thread_Control *_Scheduler_priority_affinity_SMP_Ask_for_help(
context,
offers_help,
needs_help,
- _Scheduler_priority_affinity_SMP_Enqueue_fifo,
- _Scheduler_priority_SMP_Release_idle_thread
+ _Scheduler_priority_affinity_SMP_Enqueue_fifo
);
_Scheduler_priority_affinity_SMP_Check_for_migrations( context );
diff --git a/cpukit/score/src/schedulerprioritysmp.c b/cpukit/score/src/schedulerprioritysmp.c
index 93d1c76d30..c08799f270 100644
--- a/cpukit/score/src/schedulerprioritysmp.c
+++ b/cpukit/score/src/schedulerprioritysmp.c
@@ -93,8 +93,7 @@ void _Scheduler_priority_SMP_Block(
_Scheduler_priority_SMP_Extract_from_ready,
_Scheduler_priority_SMP_Get_highest_ready,
_Scheduler_priority_SMP_Move_from_ready_to_scheduled,
- _Scheduler_SMP_Allocate_processor_lazy,
- _Scheduler_priority_SMP_Get_idle_thread
+ _Scheduler_SMP_Allocate_processor_lazy
);
}
@@ -116,8 +115,7 @@ static Thread_Control *_Scheduler_priority_SMP_Enqueue_ordered(
insert_scheduled,
_Scheduler_priority_SMP_Move_from_scheduled_to_ready,
_Scheduler_SMP_Get_lowest_scheduled,
- _Scheduler_SMP_Allocate_processor_lazy,
- _Scheduler_priority_SMP_Release_idle_thread
+ _Scheduler_SMP_Allocate_processor_lazy
);
}
@@ -170,9 +168,7 @@ static Thread_Control *_Scheduler_priority_SMP_Enqueue_scheduled_ordered(
insert_ready,
insert_scheduled,
_Scheduler_priority_SMP_Move_from_ready_to_scheduled,
- _Scheduler_SMP_Allocate_processor_lazy,
- _Scheduler_priority_SMP_Get_idle_thread,
- _Scheduler_priority_SMP_Release_idle_thread
+ _Scheduler_SMP_Allocate_processor_lazy
);
}
@@ -214,8 +210,7 @@ Thread_Control *_Scheduler_priority_SMP_Unblock(
return _Scheduler_SMP_Unblock(
context,
thread,
- _Scheduler_priority_SMP_Enqueue_fifo,
- _Scheduler_priority_SMP_Release_idle_thread
+ _Scheduler_priority_SMP_Enqueue_fifo
);
}
@@ -254,8 +249,7 @@ Thread_Control *_Scheduler_priority_SMP_Ask_for_help(
context,
offers_help,
needs_help,
- _Scheduler_priority_SMP_Enqueue_fifo,
- _Scheduler_priority_SMP_Release_idle_thread
+ _Scheduler_priority_SMP_Enqueue_fifo
);
}
diff --git a/cpukit/score/src/schedulersimplesmp.c b/cpukit/score/src/schedulersimplesmp.c
index 733f3dbe9f..0f05a7da81 100644
--- a/cpukit/score/src/schedulersimplesmp.c
+++ b/cpukit/score/src/schedulersimplesmp.c
@@ -165,28 +165,6 @@ 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
@@ -200,8 +178,7 @@ 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_simple_SMP_Get_idle_thread
+ _Scheduler_SMP_Allocate_processor_lazy
);
}
@@ -223,8 +200,7 @@ 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_simple_SMP_Release_idle_thread
+ _Scheduler_SMP_Allocate_processor_lazy
);
}
@@ -277,9 +253,7 @@ static Thread_Control *_Scheduler_simple_SMP_Enqueue_scheduled_ordered(
insert_ready,
insert_scheduled,
_Scheduler_simple_SMP_Move_from_ready_to_scheduled,
- _Scheduler_SMP_Allocate_processor_lazy,
- _Scheduler_simple_SMP_Get_idle_thread,
- _Scheduler_simple_SMP_Release_idle_thread
+ _Scheduler_SMP_Allocate_processor_lazy
);
}
@@ -321,8 +295,7 @@ Thread_Control *_Scheduler_simple_SMP_Unblock(
return _Scheduler_SMP_Unblock(
context,
thread,
- _Scheduler_simple_SMP_Enqueue_fifo,
- _Scheduler_simple_SMP_Release_idle_thread
+ _Scheduler_simple_SMP_Enqueue_fifo
);
}
@@ -361,8 +334,7 @@ Thread_Control *_Scheduler_simple_SMP_Ask_for_help(
context,
offers_help,
needs_help,
- _Scheduler_simple_SMP_Enqueue_fifo,
- _Scheduler_simple_SMP_Release_idle_thread
+ _Scheduler_simple_SMP_Enqueue_fifo
);
}