forked from Imagelibrary/rtems
score: Pass scheduler node to yield operation
Changed for consistency with other scheduler operations. Update #2556.
This commit is contained in:
@@ -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() */
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
/**@}*/
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user