Need help in understanding some of the existing code in RTEMS
Sebastian Huber
sebastian.huber at embedded-brains.de
Tue Jul 14 09:21:25 UTC 2020
On 14/07/2020 11:11, Sebastian Huber wrote:
> On 14/07/2020 10:47, Richi Dubey wrote:
>
>> Can someone please help me understand how this
>> (https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c#n385)
>> if condition works. Why are we removing the ready queue Node from the
>> chain of Affine queues when we are allocating a different processor
>> (https://git.rtems.org/rtems/tree/cpukit/score/src/scheduleredfsmp.c#n398)
>> to the node which was currently scheduled on the CPU of that (the
>> ready queue mentioned in the if condition's) ready queue?
>
> |static inline void _Scheduler_EDF_SMP_Allocate_processor(
> Scheduler_Context *context, Scheduler_Node *scheduled_base,
> Scheduler_Node *victim_base, Per_CPU_Control *victim_cpu ) {
> Scheduler_EDF_SMP_Context *self; Scheduler_EDF_SMP_Node *scheduled;
> uint8_t rqi; (void) victim_base; self = _Scheduler_EDF_SMP_Get_self(
> context ); scheduled = _Scheduler_EDF_SMP_Node_downcast(
> scheduled_base ); rqi = scheduled->ready_queue_index; if ( rqi != 0 )
> { Scheduler_EDF_SMP_Ready_queue *ready_queue; Per_CPU_Control
> *desired_cpu; ready_queue = &self->Ready[ rqi ]; if (
> !_Chain_Is_node_off_chain( &ready_queue->Node ) ) {
> _Chain_Extract_unprotected( &ready_queue->Node );
> _Chain_Set_off_chain( &ready_queue->Node ); } Here we remove the
> affine ready queue if it exists from the chain of affine queues since
> now an affine thread is scheduled on a processor. desired_cpu =
> _Per_CPU_Get_by_index( rqi - 1 ); if ( victim_cpu != desired_cpu ) {
> Scheduler_EDF_SMP_Node *node; This is another action. If the victim
> CPU is not the right one for the new scheduled node, we have to make
> room for it on the desired CPU. node =
> _Scheduler_EDF_SMP_Get_scheduled( self, rqi ); _Assert(
> node->ready_queue_index == 0 ); _Scheduler_EDF_SMP_Set_scheduled(
> self, node, victim_cpu ); _Scheduler_SMP_Allocate_processor_exact(
> context, &node->Base.Base, NULL, victim_cpu ); victim_cpu =
> desired_cpu; } }|
Sorry for the format.
static inline void _Scheduler_EDF_SMP_Allocate_processor(
Scheduler_Context *context,
Scheduler_Node *scheduled_base,
Scheduler_Node *victim_base,
Per_CPU_Control *victim_cpu
)
{
Scheduler_EDF_SMP_Context *self;
Scheduler_EDF_SMP_Node *scheduled;
uint8_t rqi;
(void) victim_base;
self = _Scheduler_EDF_SMP_Get_self( context );
scheduled = _Scheduler_EDF_SMP_Node_downcast( scheduled_base );
rqi = scheduled->ready_queue_index;
if ( rqi != 0 ) {
Scheduler_EDF_SMP_Ready_queue *ready_queue;
Per_CPU_Control *desired_cpu;
ready_queue = &self->Ready[ rqi ];
if ( !_Chain_Is_node_off_chain( &ready_queue->Node ) ) {
_Chain_Extract_unprotected( &ready_queue->Node );
_Chain_Set_off_chain( &ready_queue->Node );
}
Here we remove the affine ready queue if it exists from the chain of
affine queues since now an affine thread is scheduled on a processor.
desired_cpu = _Per_CPU_Get_by_index( rqi - 1 );
if ( victim_cpu != desired_cpu ) {
Scheduler_EDF_SMP_Node *node;
This is another action. If the victim CPU is not the right one for the
new scheduled node, we have to make room for it on the desired CPU.
node = _Scheduler_EDF_SMP_Get_scheduled( self, rqi );
_Assert( node->ready_queue_index == 0 );
_Scheduler_EDF_SMP_Set_scheduled( self, node, victim_cpu );
_Scheduler_SMP_Allocate_processor_exact(
context,
&node->Base.Base,
NULL,
victim_cpu
);
victim_cpu = desired_cpu;
}
}
More information about the devel
mailing list