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

Richi Dubey richidubey at gmail.com
Thu Aug 13 15:27:52 UTC 2020


Thanks,

But I still can't find the code that links the 'Ready' in this

>>  #define RTEMS_SCHEDULER_EDF_SMP( name ) \
>>      static struct { \
>>        Scheduler_EDF_SMP_Context Base; \
>>        Scheduler_EDF_SMP_Ready_queue Ready[ CONFIGURE_MAXIMUM_PROCESSORS
>> + 1 ]; \

to the 'Ready' in scheduleredfsmp.h:

typedef struct {
  Scheduler_SMP_Context Base;

  /**
   * @brief Current generation for LIFO (index 0) and FIFO (index 1)
ordering.
   */
  int64_t generations[ 2 ];

  /**
   * @brief Chain of ready queues with affine threads to determine the
highest
   * priority ready thread.
   */
  Chain_Control Affine_queues;

  /**
   * @brief A table with ready queues.
   *
   * The index zero queue is used for threads with a one-to-all processor
   * affinity.  Index one corresponds to processor index zero, and so on.
   */
  Scheduler_EDF_SMP_Ready_queue Ready[ RTEMS_ZERO_LENGTH_ARRAY ];
} Scheduler_EDF_SMP_Context;

If I figure this out, everything else would make sense too. Please help me
out.

On Thu, Aug 13, 2020 at 8:47 PM Gedare Bloom <gedare at rtems.org> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20200813/b5c195dc/attachment.html>


More information about the devel mailing list