Need help in understanding some of the existing code in RTEMS

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Jul 16 15:47:33 UTC 2020


On 15/07/2020 14:55, Richi Dubey wrote:

> On Wed, Jul 15, 2020 at 5:57 PM Richi Dubey <richidubey at gmail.com 
> <mailto:richidubey at gmail.com>> wrote:
>
>     Hi,
>
>     I had a small question. The scheduler struct inside percpu.h looks
>     like:
>     ------------------------------------------------------------------------------------------------------
>         struct {
>           /**
>            * @brief The scheduler control of the scheduler owning this
>     processor.
>            *
>            * This pointer is NULL in case this processor is currently
>     not used by a
>            * scheduler instance.
>            */
>           const struct _Scheduler_Control *control;
>
>           /**
>            * @brief The scheduler context of the scheduler owning this
>     processor.
>            *
>            * This pointer is NULL in case this processor is currently
>     not used by a
>            * scheduler instance.
>            */
>           const struct Scheduler_Context *context;
>
>           /**
>            * @brief The idle thread for this processor in case it is
>     online and
>            * currently not used by a scheduler instance.
>            */
>           struct _Thread_Control *idle_if_online_and_unused;
>         } Scheduler;
>     ------------------------------------------------------------------------------------------------------
>     So, does this mean a CPU when active is always either executing an
>     idle thread and is not being used by a scheduler (so has a thread
>     attribute in the idle_if_online_and_unused), or is used by a
>     scheduler and is executing a task ( which can not be an idle
>     task)? Another equivalent question is do we have an idle scheduler
>     node, like we have idle predefined threads that run on a CPU?
>
During system startup the application configuration defines which 
processor is available to RTEMS. Every configured and present processor 
gets an idle thread assigned which is managed by a scheduler. This is 
the starting point of the system. If someone calls 
rtems_scheduler_remove_processor(), then a processor gets removed from a 
scheduler instance. This processor still has to execute code. For this a 
idle thread is used. This idle thread is not managed by a scheduler. If 
someone uses rtems_scheduler_add_processor() this idle thread is again 
controlled by a scheduler.



More information about the devel mailing list