Small doubt in importance of Scheduler_Context for uniprocessor schedulers

Gedare Bloom gedare at rtems.org
Sat Jun 13 18:04:42 UTC 2020


On Sat, Jun 13, 2020 at 11:41 AM Richi Dubey <richidubey at gmail.com> wrote:
>
> Hi,
>
> I was going through the deterministic scheduler for uniprocessor and noticed in the code:
> ------------------------------------------------------------------------------------------------
>  "cpukit/include/rtems/score/schedulerpriority.h" :
>
> typedef struct {
>   /**
>    * @brief Basic scheduler context.
>    */
>   Scheduler_Context Base;
>
>   /**
>    * @brief Bit map to indicate non-empty ready queues.
>    */
>   Priority_bit_map_Control Bit_map;
>
>   /**
>    * @brief One ready queue per priority level.
>    */
>   Chain_Control Ready[ 0 ];
> } Scheduler_priority_Context;
> -----------------------------------------------------------------------------------
>
> Where Scheduler_Context is defined as:
>
> -----------------------------------------------------------------------------
>
> From "cpukit/include/rtems/score/scheduler.h":
>
> typedef struct Scheduler_Context {
>   /**
>    * @brief Lock to protect this scheduler instance.
>    */
>   ISR_LOCK_MEMBER( Lock )
>
> #if defined(RTEMS_SMP)
>   /**
>    * @brief The set of processors owned by this scheduler instance.
>    */
>   Processor_mask Processors;
> #endif
> } Scheduler_Context;
>
> -------------------------------------------------------------------------------------------------
>
> and ISR_LOCK is defined as:
>
> ------------------------------------------------------------------------------------------------------
>
> "cpukit/include/rtems/score/isrlock.h"
>
> /**
>  * @brief Defines an ISR lock member.
>  *
>  * Do not add a ';' after this macro.
>  *
>  * @param _designator The designator for the interrupt lock.
>  */
> #if defined( RTEMS_SMP )
>   #define ISR_LOCK_MEMBER( _designator ) ISR_lock_Control _designator;
> #else
>   #define ISR_LOCK_MEMBER( _designator )
> #endif
> "cpukit/include/rtems/score/isrlock.h"
> --------------------------------------------------------------------------------------------
> Since we left the preprocessor directive as empty for the else case, it means that for a non smp system, we don't use the ISR_LOCK as well as the processor mask.
>
> Then could someone please help me understand why we would include Scheduler_Context Base in the Scheduler_priority_Context since this scheduler is for a uniprocessor system and Scheduler_Context has nothing?
>

I think it's there for consistency.

> Thanks,
> Richi.
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list