Need help in figuring out how to allocate sizes to the array

Gedare Bloom gedare at rtems.org
Thu Aug 13 15:16:57 UTC 2020


On Thu, Aug 13, 2020 at 8:34 AM Richi Dubey <richidubey at gmail.com> wrote:
>
> Thanks,
>  I am assuming this is the code that allocates space:
>
>>  #define RTEMS_SCHEDULER_EDF_SMP( name ) \
>>      static struct { \
>>        Scheduler_EDF_SMP_Context Base; \
>>        Scheduler_EDF_SMP_Ready_queue Ready[ CONFIGURE_MAXIMUM_PROCESSORS
>> + 1 ]; \
>>      } SCHEDULER_EDF_SMP_CONTEXT_NAME( name )
>
This is declaring a structure type that will have a particular format
of the struct name.

>
> How do we use or refer to this 'Base'? How do we link this 'Ready' to the 'Ready' inside the EDF_SMP_Context?
>

This stuff gets set up during confdefs step. Eventually the scheduler
contexts are instantiated in the scheduler table.

confdefs/scheduler.h:
    #define CONFIGURE_SCHEDULER RTEMS_SCHEDULER_EDF_SMP( dflt )

    #define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
      RTEMS_SCHEDULER_TABLE_EDF_SMP( dflt, CONFIGURE_SCHEDULER_NAME )
....
const Scheduler_Control _Scheduler_Table[] = {
  CONFIGURE_SCHEDULER_TABLE_ENTRIES
};

This is where the space actually gets allocated, based on how
CONFIGURE_SCHEDULER_TABLE_ENTRIES gets defined up to here from the CPP
macros.



> On Thu, Aug 13, 2020 at 6:17 PM Sebastian Huber <sebastian.huber at embedded-brains.de> wrote:
> >
> > On 13/08/2020 14:42, Richi Dubey wrote:
> >
> > > I want to use arrays with size _CONFIGURE_MAXIMUM_PROCESSORS. Is it
> > > okay if I define the arrays with this size while writing the scheduler
> > > strong APA header file? I am asking this because the value of this
> > > header gets defined at the time the test case runs while the scheduler
> > > gets linked to the test case at the time of linking. So how would it
> > > work?
> >
> > Do NOT use _CONFIGURE_MAXIMUM_PROCESSORS.
> >
> > In <rtems/scheduler.h> please use something similar to the EDF scheduler
> > instantiation:
> >
> > #ifdef CONFIGURE_SCHEDULER_EDF_SMP
> >    #include <rtems/score/scheduleredfsmp.h>
> >
> >    #ifndef CONFIGURE_MAXIMUM_PROCESSORS
> >      #error "CONFIGURE_MAXIMUM_PROCESSORS must be defined to configure
> > the EDF SMP scheduler"
> >    #endif
> >
> >    #define SCHEDULER_EDF_SMP_CONTEXT_NAME( name ) \
> >      SCHEDULER_CONTEXT_NAME( EDF_SMP_ ## name )
> >
> >    #define RTEMS_SCHEDULER_EDF_SMP( name ) \
> >      static struct { \
> >        Scheduler_EDF_SMP_Context Base; \
> >        Scheduler_EDF_SMP_Ready_queue Ready[ CONFIGURE_MAXIMUM_PROCESSORS
> > + 1 ]; \
> >      } SCHEDULER_EDF_SMP_CONTEXT_NAME( name )
> >
> >    #define RTEMS_SCHEDULER_TABLE_EDF_SMP( name, obj_name ) \
> >      { \
> >        &SCHEDULER_EDF_SMP_CONTEXT_NAME( name ).Base.Base.Base, \
> >        SCHEDULER_EDF_SMP_ENTRY_POINTS, \
> >        SCHEDULER_EDF_MAXIMUM_PRIORITY, \
> >        ( obj_name ) \
> >        SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( false ) \
> >      }
> >
> >    /* Provided for backward compatibility */
> >
> >    #define RTEMS_SCHEDULER_CONTEXT_EDF_SMP( name, max_cpu_count ) \
> >      RTEMS_SCHEDULER_EDF_SMP( name )
> >
> >    #define RTEMS_SCHEDULER_CONTROL_EDF_SMP( name, obj_name ) \
> >      RTEMS_SCHEDULER_TABLE_EDF_SMP( name, obj_name )
> > #endif
> >
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list