[PATCH 04/30] score: Pass scheduler node to yield operation
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Oct 31 08:51:35 UTC 2016
Changed for consistency with other scheduler operations.
Update #2556.
---
cpukit/score/include/rtems/score/scheduler.h | 3 ++-
cpukit/score/include/rtems/score/scheduleredf.h | 19 ++----------------
cpukit/score/include/rtems/score/schedulerimpl.h | 6 +++++-
.../score/include/rtems/score/schedulerpriority.h | 23 ++--------------------
.../include/rtems/score/schedulerprioritysmp.h | 3 ++-
cpukit/score/include/rtems/score/schedulersimple.h | 20 ++-----------------
.../score/include/rtems/score/schedulersimplesmp.h | 3 ++-
.../score/include/rtems/score/schedulersmpimpl.h | 12 +++++------
.../score/include/rtems/score/schedulerstrongapa.h | 3 ++-
cpukit/score/src/scheduleredfyield.c | 11 ++++++-----
cpukit/score/src/schedulerprioritysmp.c | 4 +++-
cpukit/score/src/schedulerpriorityyield.c | 10 +++++++---
cpukit/score/src/schedulersimplesmp.c | 4 +++-
cpukit/score/src/schedulersimpleyield.c | 5 ++++-
cpukit/score/src/schedulerstrongapa.c | 4 +++-
testsuites/smptests/smpscheduler03/init.c | 13 +++++++++---
16 files changed, 61 insertions(+), 82 deletions(-)
diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h
index 0fc7d5a..745fbec 100644
--- a/cpukit/score/include/rtems/score/scheduler.h
+++ b/cpukit/score/include/rtems/score/scheduler.h
@@ -65,7 +65,8 @@ typedef struct {
/** @see _Scheduler_Yield() */
Scheduler_Void_or_thread ( *yield )(
const Scheduler_Control *,
- Thread_Control *
+ Thread_Control *,
+ Scheduler_Node *
);
/** @see _Scheduler_Block() */
diff --git a/cpukit/score/include/rtems/score/scheduleredf.h b/cpukit/score/include/rtems/score/scheduleredf.h
index 0ae33cf..005f2da 100644
--- a/cpukit/score/include/rtems/score/scheduleredf.h
+++ b/cpukit/score/include/rtems/score/scheduleredf.h
@@ -185,25 +185,10 @@ Priority_Control _Scheduler_EDF_Unmap_priority(
Priority_Control priority
);
-/**
- * @brief invoked when a thread wishes to voluntarily
- * transfer control of the processor to another thread
- * with equal deadline.
- *
- * This routine is invoked when a thread wishes to voluntarily
- * transfer control of the processor to another thread in the queue with
- * equal deadline. This does not have to happen very often.
- *
- * This routine will remove the specified THREAD from the ready queue
- * and place it back. The rbtree ready queue is responsible for FIFO ordering
- * in such a case.
- *
- * @param[in] scheduler The scheduler instance.
- * @param[in,out] the_thread The yielding thread.
- */
Scheduler_Void_or_thread _Scheduler_EDF_Yield(
const Scheduler_Control *scheduler,
- Thread_Control *the_thread
+ Thread_Control *the_thread,
+ Scheduler_Node *node
);
void _Scheduler_EDF_Release_job(
diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h
index 211b7a7..a431a3a 100644
--- a/cpukit/score/include/rtems/score/schedulerimpl.h
+++ b/cpukit/score/include/rtems/score/schedulerimpl.h
@@ -299,7 +299,11 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Yield( Thread_Control *the_thread )
#if defined(RTEMS_SMP)
needs_help =
#endif
- ( *scheduler->Operations.yield )( scheduler, the_thread );
+ ( *scheduler->Operations.yield )(
+ scheduler,
+ the_thread,
+ _Thread_Scheduler_get_home_node( the_thread )
+ );
#if defined(RTEMS_SMP)
_Scheduler_Ask_for_help_if_necessary( needs_help );
diff --git a/cpukit/score/include/rtems/score/schedulerpriority.h b/cpukit/score/include/rtems/score/schedulerpriority.h
index 4c9c698..175def4 100644
--- a/cpukit/score/include/rtems/score/schedulerpriority.h
+++ b/cpukit/score/include/rtems/score/schedulerpriority.h
@@ -166,29 +166,10 @@ void _Scheduler_priority_Node_initialize(
Priority_Control priority
);
-/**
- * @brief The specified THREAD yields.
- *
- * This routine is invoked when a thread wishes to voluntarily
- * transfer control of the processor to another thread in the queue.
- *
- * This routine will remove the specified THREAD from the ready queue
- * and place it immediately at the rear of this chain. Reset timeslice
- * and yield the processor functions both use this routine, therefore if
- * reset is true and this is the only thread on the queue then the
- * timeslice counter is reset. The heir THREAD will be updated if the
- * running is also the currently the heir.
- *
- * - INTERRUPT LATENCY:
- * + ready chain
- * + select heir
- *
- * @param[in] scheduler The scheduler instance.
- * @param[in,out] the_thread The yielding thread.
- */
Scheduler_Void_or_thread _Scheduler_priority_Yield(
const Scheduler_Control *scheduler,
- Thread_Control *the_thread
+ Thread_Control *the_thread,
+ Scheduler_Node *node
);
/**@}*/
diff --git a/cpukit/score/include/rtems/score/schedulerprioritysmp.h b/cpukit/score/include/rtems/score/schedulerprioritysmp.h
index afde45b..8350038 100644
--- a/cpukit/score/include/rtems/score/schedulerprioritysmp.h
+++ b/cpukit/score/include/rtems/score/schedulerprioritysmp.h
@@ -129,7 +129,8 @@ Thread_Control *_Scheduler_priority_SMP_Ask_for_help_X(
Thread_Control *_Scheduler_priority_SMP_Yield(
const Scheduler_Control *scheduler,
- Thread_Control *thread
+ Thread_Control *thread,
+ Scheduler_Node *node
);
/** @} */
diff --git a/cpukit/score/include/rtems/score/schedulersimple.h b/cpukit/score/include/rtems/score/schedulersimple.h
index 5d61069..d8bc02e 100644
--- a/cpukit/score/include/rtems/score/schedulersimple.h
+++ b/cpukit/score/include/rtems/score/schedulersimple.h
@@ -92,26 +92,10 @@ void _Scheduler_simple_Schedule(
Thread_Control *the_thread
);
-/**
- * @brief Invoked when a thread wishes to voluntarily
- * transfer control of the processor to another thread in the queue.
- *
- * This routine is invoked when a thread wishes to voluntarily
- * transfer control of the processor to another thread in the queue.
- * It will remove the specified THREAD from the scheduler.informaiton
- * (where the ready queue is stored) and place it immediately at the
- * between the last entry of its priority and the next priority thread.
- * Reset timeslice and yield the processor functions both use this routine,
- * therefore if reset is true and this is the only thread on the queue then
- * the timeslice counter is reset. The heir THREAD will be updated if the
- * running is also the currently the heir.
- *
- * @param[in] scheduler The scheduler instance.
- * @param[in,out] the_thread The yielding thread.
- */
Scheduler_Void_or_thread _Scheduler_simple_Yield(
const Scheduler_Control *scheduler,
- Thread_Control *the_thread
+ Thread_Control *the_thread,
+ Scheduler_Node *node
);
/**
diff --git a/cpukit/score/include/rtems/score/schedulersimplesmp.h b/cpukit/score/include/rtems/score/schedulersimplesmp.h
index 4273445..36f5fb3 100644
--- a/cpukit/score/include/rtems/score/schedulersimplesmp.h
+++ b/cpukit/score/include/rtems/score/schedulersimplesmp.h
@@ -112,7 +112,8 @@ Thread_Control *_Scheduler_simple_SMP_Ask_for_help_X(
Thread_Control *_Scheduler_simple_SMP_Yield(
const Scheduler_Control *scheduler,
- Thread_Control *thread
+ Thread_Control *thread,
+ Scheduler_Node *node
);
/** @} */
diff --git a/cpukit/score/include/rtems/score/schedulersmpimpl.h b/cpukit/score/include/rtems/score/schedulersmpimpl.h
index cec0357..6deb160 100644
--- a/cpukit/score/include/rtems/score/schedulersmpimpl.h
+++ b/cpukit/score/include/rtems/score/schedulersmpimpl.h
@@ -1084,22 +1084,22 @@ static inline Thread_Control *_Scheduler_SMP_Ask_for_help_X(
static inline Thread_Control *_Scheduler_SMP_Yield(
Scheduler_Context *context,
Thread_Control *thread,
+ Scheduler_Node *node,
Scheduler_SMP_Extract extract_from_ready,
Scheduler_SMP_Enqueue enqueue_fifo,
Scheduler_SMP_Enqueue_scheduled enqueue_scheduled_fifo
)
{
- Scheduler_SMP_Node *node = _Scheduler_SMP_Thread_get_node( thread );
Thread_Control *needs_help;
- if ( node->state == SCHEDULER_SMP_NODE_SCHEDULED ) {
- _Scheduler_SMP_Extract_from_scheduled( &node->Base );
+ if ( _Scheduler_SMP_Node_state( node ) == SCHEDULER_SMP_NODE_SCHEDULED ) {
+ _Scheduler_SMP_Extract_from_scheduled( node );
- needs_help = ( *enqueue_scheduled_fifo )( context, &node->Base );
+ needs_help = ( *enqueue_scheduled_fifo )( context, node );
} else {
- ( *extract_from_ready )( context, &node->Base );
+ ( *extract_from_ready )( context, node );
- needs_help = ( *enqueue_fifo )( context, &node->Base, NULL );
+ needs_help = ( *enqueue_fifo )( context, node, NULL );
}
return needs_help;
diff --git a/cpukit/score/include/rtems/score/schedulerstrongapa.h b/cpukit/score/include/rtems/score/schedulerstrongapa.h
index 35d3edd..aa352e2 100644
--- a/cpukit/score/include/rtems/score/schedulerstrongapa.h
+++ b/cpukit/score/include/rtems/score/schedulerstrongapa.h
@@ -129,7 +129,8 @@ Thread_Control *_Scheduler_strong_APA_Ask_for_help_X(
Thread_Control *_Scheduler_strong_APA_Yield(
const Scheduler_Control *scheduler,
- Thread_Control *the_thread
+ Thread_Control *the_thread,
+ Scheduler_Node *node
);
/** @} */
diff --git a/cpukit/score/src/scheduleredfyield.c b/cpukit/score/src/scheduleredfyield.c
index 3e64e5c..a54b1f5 100644
--- a/cpukit/score/src/scheduleredfyield.c
+++ b/cpukit/score/src/scheduleredfyield.c
@@ -23,17 +23,18 @@
Scheduler_Void_or_thread _Scheduler_EDF_Yield(
const Scheduler_Control *scheduler,
- Thread_Control *the_thread
+ Thread_Control *the_thread,
+ Scheduler_Node *node
)
{
Scheduler_EDF_Context *context;
- Scheduler_EDF_Node *node;
+ Scheduler_EDF_Node *the_node;
context = _Scheduler_EDF_Get_context( scheduler );
- node = _Scheduler_EDF_Thread_get_node( the_thread );
+ the_node = _Scheduler_EDF_Node_downcast( node );
- _Scheduler_EDF_Extract( context, node );
- _Scheduler_EDF_Enqueue( context, node, node->priority );
+ _Scheduler_EDF_Extract( context, the_node );
+ _Scheduler_EDF_Enqueue( context, the_node, the_node->priority );
_Scheduler_EDF_Schedule_body( scheduler, the_thread, true );
SCHEDULER_RETURN_VOID_OR_NULL;
diff --git a/cpukit/score/src/schedulerprioritysmp.c b/cpukit/score/src/schedulerprioritysmp.c
index 4936b05..3c88161 100644
--- a/cpukit/score/src/schedulerprioritysmp.c
+++ b/cpukit/score/src/schedulerprioritysmp.c
@@ -264,7 +264,8 @@ Thread_Control *_Scheduler_priority_SMP_Ask_for_help_X(
Thread_Control *_Scheduler_priority_SMP_Yield(
const Scheduler_Control *scheduler,
- Thread_Control *thread
+ Thread_Control *thread,
+ Scheduler_Node *node
)
{
Scheduler_Context *context = _Scheduler_Get_context( scheduler );
@@ -272,6 +273,7 @@ Thread_Control *_Scheduler_priority_SMP_Yield(
return _Scheduler_SMP_Yield(
context,
thread,
+ node,
_Scheduler_priority_SMP_Extract_from_ready,
_Scheduler_priority_SMP_Enqueue_fifo,
_Scheduler_priority_SMP_Enqueue_scheduled_fifo
diff --git a/cpukit/score/src/schedulerpriorityyield.c b/cpukit/score/src/schedulerpriorityyield.c
index 5dab094..4d22dc9 100644
--- a/cpukit/score/src/schedulerpriorityyield.c
+++ b/cpukit/score/src/schedulerpriorityyield.c
@@ -23,11 +23,15 @@
Scheduler_Void_or_thread _Scheduler_priority_Yield(
const Scheduler_Control *scheduler,
- Thread_Control *the_thread
+ Thread_Control *the_thread,
+ Scheduler_Node *node
)
{
- Scheduler_priority_Node *node = _Scheduler_priority_Thread_get_node( the_thread );
- Chain_Control *ready_chain = node->Ready_queue.ready_chain;
+ Scheduler_priority_Node *the_node;
+ Chain_Control *ready_chain;
+
+ the_node = _Scheduler_priority_Node_downcast( node );
+ ready_chain = the_node->Ready_queue.ready_chain;
if ( !_Chain_Has_only_one_node( ready_chain ) ) {
_Chain_Extract_unprotected( &the_thread->Object.Node );
diff --git a/cpukit/score/src/schedulersimplesmp.c b/cpukit/score/src/schedulersimplesmp.c
index 2d333c9..b476c08 100644
--- a/cpukit/score/src/schedulersimplesmp.c
+++ b/cpukit/score/src/schedulersimplesmp.c
@@ -331,7 +331,8 @@ Thread_Control *_Scheduler_simple_SMP_Ask_for_help_X(
Thread_Control *_Scheduler_simple_SMP_Yield(
const Scheduler_Control *scheduler,
- Thread_Control *thread
+ Thread_Control *thread,
+ Scheduler_Node *node
)
{
Scheduler_Context *context = _Scheduler_Get_context( scheduler );
@@ -339,6 +340,7 @@ Thread_Control *_Scheduler_simple_SMP_Yield(
return _Scheduler_SMP_Yield(
context,
thread,
+ node,
_Scheduler_simple_SMP_Extract_from_ready,
_Scheduler_simple_SMP_Enqueue_fifo,
_Scheduler_simple_SMP_Enqueue_scheduled_fifo
diff --git a/cpukit/score/src/schedulersimpleyield.c b/cpukit/score/src/schedulersimpleyield.c
index 66e4450..cfd123f 100644
--- a/cpukit/score/src/schedulersimpleyield.c
+++ b/cpukit/score/src/schedulersimpleyield.c
@@ -22,12 +22,15 @@
Scheduler_Void_or_thread _Scheduler_simple_Yield(
const Scheduler_Control *scheduler,
- Thread_Control *the_thread
+ Thread_Control *the_thread,
+ Scheduler_Node *node
)
{
Scheduler_simple_Context *context =
_Scheduler_simple_Get_context( scheduler );
+ (void) node;
+
_Chain_Extract_unprotected( &the_thread->Object.Node );
_Scheduler_simple_Insert_priority_fifo( &context->Ready, the_thread );
_Scheduler_simple_Schedule_body( scheduler, the_thread, false );
diff --git a/cpukit/score/src/schedulerstrongapa.c b/cpukit/score/src/schedulerstrongapa.c
index f42f470..2b2f4e4 100644
--- a/cpukit/score/src/schedulerstrongapa.c
+++ b/cpukit/score/src/schedulerstrongapa.c
@@ -390,7 +390,8 @@ Thread_Control *_Scheduler_strong_APA_Ask_for_help_X(
Thread_Control *_Scheduler_strong_APA_Yield(
const Scheduler_Control *scheduler,
- Thread_Control *the_thread
+ Thread_Control *the_thread,
+ Scheduler_Node *node
)
{
Scheduler_Context *context = _Scheduler_Get_context( scheduler );
@@ -398,6 +399,7 @@ Thread_Control *_Scheduler_strong_APA_Yield(
return _Scheduler_SMP_Yield(
context,
the_thread,
+ node,
_Scheduler_strong_APA_Extract_from_ready,
_Scheduler_strong_APA_Enqueue_fifo,
_Scheduler_strong_APA_Enqueue_scheduled_fifo
diff --git a/testsuites/smptests/smpscheduler03/init.c b/testsuites/smptests/smpscheduler03/init.c
index f450606..f9588a3 100644
--- a/testsuites/smptests/smpscheduler03/init.c
+++ b/testsuites/smptests/smpscheduler03/init.c
@@ -320,7 +320,10 @@ static void test_update_priority_op(void)
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
-static Thread_Control *yield_op(Thread_Control *thread)
+static Thread_Control *yield_op(
+ Thread_Control *thread,
+ Scheduler_SMP_Node *scheduler_node
+)
{
const Scheduler_Control *scheduler;
ISR_lock_Context state_lock_context;
@@ -331,7 +334,11 @@ static Thread_Control *yield_op(Thread_Control *thread)
scheduler = _Scheduler_Get( thread );
_Scheduler_Acquire_critical( scheduler, &scheduler_lock_context );
- needs_help = (*scheduler->Operations.yield)(scheduler, thread);
+ needs_help = (*scheduler->Operations.yield)(
+ scheduler,
+ thread,
+ &scheduler_node->Base
+ );
_Scheduler_Release_critical( scheduler, &scheduler_lock_context );
_Thread_State_release( thread, &state_lock_context );
@@ -391,7 +398,7 @@ static void test_case_yield_op(
}
rtems_test_assert(executing_node->state == start_state);
- needs_help = yield_op(executing);
+ needs_help = yield_op(executing, executing_node);
rtems_test_assert(executing_node->state == new_state);
if (start_state != new_state) {
--
1.8.4.5
More information about the devel
mailing list