Changeset 69aa3349 in rtems for cpukit/sapi


Ignore:
Timestamp:
Apr 8, 2014, 7:42:29 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
0712d17
Parents:
e1598a6
git-author:
Sebastian Huber <sebastian.huber@…> (04/08/14 07:42:29)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/15/14 06:37:12)
Message:

score: Simplify thread control initialization

The thread control block contains fields that point to application
configuration dependent memory areas, like the scheduler information,
the API control blocks, the user extension context table, the RTEMS
notepads and the Newlib re-entrancy support. Account for these areas in
the configuration and avoid extra workspace allocations for these areas.

This helps also to avoid heap fragementation and reduces the per thread
memory due to a reduced heap allocation overhead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/sapi/include/confdefs.h

    re1598a6 r69aa3349  
    642642 *    - CONFIGURE_SCHEDULER_CONTEXT
    643643 *    - CONFIGURE_SCHEDULER_CONTROLS
    644  *    - CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER - per task memory
     644 *    - CONFIGURE_SCHEDULER_USER_PER_THREAD
    645645 */
    646646
     
    677677      RTEMS_SCHEDULER_CONTROL_PRIORITY(dflt)
    678678  #endif
    679 
    680   /**
    681    * This defines the memory used by the priority scheduler.
    682    */
    683   #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER ( \
    684     _Configure_From_workspace(sizeof(Scheduler_priority_Per_thread)) )
    685679#endif
    686680
     
    700694      RTEMS_SCHEDULER_CONTROL_PRIORITY_SMP(dflt)
    701695  #endif
    702 
    703   /**
    704    * This defines the memory used by the priority scheduler.
    705    */
    706   #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER ( \
    707     _Configure_From_workspace(sizeof(Scheduler_priority_Per_thread)) )
    708696#endif
    709697
     
    723711      RTEMS_SCHEDULER_CONTROL_PRIORITY_AFFINITY_SMP(dflt)
    724712  #endif
    725 
    726   /**
    727    * This defines the memory used by the priority scheduler.
    728    */
    729   #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER ( \
    730     _Configure_From_workspace(sizeof(Scheduler_priority_Per_thread)) )
    731713#endif
    732714
     
    740722    #define CONFIGURE_SCHEDULER_CONTROLS RTEMS_SCHEDULER_CONTROL_SIMPLE(dflt)
    741723  #endif
    742 
    743   /**
    744    * define the memory used by the simple scheduler
    745    */
    746   #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER (0)
    747724#endif
    748725
     
    758735      RTEMS_SCHEDULER_CONTROL_SIMPLE_SMP(dflt)
    759736  #endif
    760 
    761   /**
    762    * Define the memory used by the Simple SMP Scheduler
    763    *
    764    * NOTE: This is the same as the Simple Scheduler
    765    */
    766   #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER (0)
    767737#endif
    768738
     
    776746    #define CONFIGURE_SCHEDULER_CONTROLS RTEMS_SCHEDULER_CONTROL_EDF(dflt)
    777747  #endif
    778 
    779   /**
    780    * define the memory used by the EDF scheduler
    781    */
    782   #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER ( \
    783     _Configure_From_workspace(sizeof(Scheduler_EDF_Per_thread)))
    784748#endif
    785749
     
    805769      _Scheduler_CBS_Server_list[ CONFIGURE_CBS_MAXIMUM_SERVERS ];
    806770  #endif
    807 
    808   /**
    809    * define the memory used by the CBS scheduler
    810    */
    811   #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER ( \
    812     _Configure_From_workspace(sizeof(Scheduler_CBS_Per_thread)))
    813771#endif
    814772
     
    15951553  #else
    15961554    #define CONFIGURE_NOTEPADS_ENABLED           FALSE
    1597   #endif
    1598 
    1599   #ifndef CONFIGURE_DISABLE_CLASSIC_API_NOTEPADS
    1600     #define CONFIGURE_MEMORY_PER_TASK_FOR_CLASSIC_API \
    1601       _Configure_From_workspace( sizeof(RTEMS_API_Control) )
    1602   #else
    1603     #define CONFIGURE_MEMORY_PER_TASK_FOR_CLASSIC_API \
    1604       _Configure_From_workspace( sizeof(RTEMS_API_Control) - \
    1605         (RTEMS_NUMBER_NOTEPADS * sizeof(uint32_t)))
    16061555  #endif
    16071556
     
    18401789    #define CONFIGURE_MAXIMUM_POSIX_THREADS 0
    18411790  #endif
    1842 
    1843   #define CONFIGURE_MEMORY_PER_TASK_FOR_POSIX_API \
    1844     _Configure_From_workspace(sizeof(POSIX_API_Control))
    18451791
    18461792  #ifndef CONFIGURE_MAXIMUM_POSIX_MUTEXES
     
    19801926
    19811927  #define CONFIGURE_MAXIMUM_POSIX_THREADS         0
    1982   #define CONFIGURE_MEMORY_PER_TASK_FOR_POSIX_API 0
    19831928  #define CONFIGURE_MEMORY_FOR_POSIX              0
    19841929
     
    20572002#endif
    20582003
    2059 #ifndef RTEMS_SCHEDSIM
    2060 /**
    2061  * This macro specifies the amount of memory to be reserved for the
    2062  * Newlib C Library reentrancy structure -- if we are using newlib.
    2063  */
    2064 
    2065 #if (defined(RTEMS_NEWLIB) && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY))
    2066   #define CONFIGURE_MEMORY_PER_TASK_FOR_NEWLIB \
    2067     _Configure_From_workspace(sizeof(struct _reent))
    2068 #else
    2069   #define CONFIGURE_MEMORY_PER_TASK_FOR_NEWLIB 0
    2070 #endif
    2071 
    2072 #else
    2073   #define CONFIGURE_MEMORY_PER_TASK_FOR_NEWLIB 0
    2074 #endif
    2075 
    20762004/**
    20772005 * This is so we can account for tasks with stacks greater than minimum
     
    21052033#define CONFIGURE_MEMORY_FOR_TASKS(_tasks, _number_FP_tasks) \
    21062034  ( \
    2107     _Configure_Object_RAM(_tasks, sizeof(Thread_Control)) \
    2108       + _Configure_Max_Objects(_tasks) \
    2109         * ( \
    2110             CONFIGURE_MEMORY_PER_TASK_FOR_CLASSIC_API \
    2111               + CONFIGURE_MEMORY_PER_TASK_FOR_NEWLIB \
    2112               + CONFIGURE_MEMORY_PER_TASK_FOR_POSIX_API \
    2113               + CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER \
    2114               + _Configure_From_workspace( \
    2115                 (CONFIGURE_MAXIMUM_USER_EXTENSIONS + 1) * sizeof(void *) \
    2116               ) \
    2117           ) \
     2035    _Configure_Object_RAM(_tasks, sizeof(Configuration_Thread_control)) \
    21182036      + _Configure_Max_Objects(_number_FP_tasks) \
    21192037        * _Configure_From_workspace(CONTEXT_FP_SIZE) \
     
    23812299
    23822300#ifdef CONFIGURE_INIT
     2301  typedef struct {
     2302    Thread_Control Control;
     2303    #if CONFIGURE_MAXIMUM_USER_EXTENSIONS > 0
     2304      void *extensions[ CONFIGURE_MAXIMUM_USER_EXTENSIONS + 1 ];
     2305    #endif
     2306    union {
     2307      #ifdef CONFIGURE_SCHEDULER_CBS
     2308        Scheduler_CBS_Per_thread CBS;
     2309      #endif
     2310      #ifdef CONFIGURE_SCHEDULER_EDF
     2311        Scheduler_EDF_Per_thread EDF;
     2312      #endif
     2313      #if defined(CONFIGURE_SCHEDULER_PRIORITY) \
     2314        || defined(CONFIGURE_SCHEDULER_PRIORITY_SMP)
     2315        Scheduler_priority_Per_thread Priority;
     2316      #endif
     2317      #ifdef CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP
     2318        Scheduler_priority_affinity_SMP_Per_thread Priority_affinity;
     2319      #endif
     2320      #ifdef CONFIGURE_SCHEDULER_USER_PER_THREAD
     2321        CONFIGURE_SCHEDULER_USER_PER_THREAD User;
     2322      #endif
     2323    } Scheduler;
     2324    RTEMS_API_Control API_RTEMS;
     2325    #ifndef CONFIGURE_DISABLE_CLASSIC_API_NOTEPADS
     2326      uint32_t Notepads[ RTEMS_NUMBER_NOTEPADS ];
     2327    #endif
     2328    #ifdef RTEMS_POSIX_API
     2329      POSIX_API_Control API_POSIX;
     2330    #endif
     2331    #if !defined(RTEMS_SCHEDSIM) \
     2332      && defined(RTEMS_NEWLIB) \
     2333      && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY)
     2334      struct _reent Newlib;
     2335    #else
     2336      struct { /* Empty */ } Newlib;
     2337    #endif
     2338  } Configuration_Thread_control;
     2339
     2340  const size_t _Thread_Control_size = sizeof( Configuration_Thread_control );
     2341
     2342  const Thread_Control_add_on _Thread_Control_add_ons[] = {
     2343    {
     2344      offsetof( Configuration_Thread_control, Control.scheduler_info ),
     2345      offsetof( Configuration_Thread_control, Scheduler )
     2346    }, {
     2347      offsetof(
     2348        Configuration_Thread_control,
     2349        Control.API_Extensions[ THREAD_API_RTEMS ]
     2350      ),
     2351      offsetof( Configuration_Thread_control, API_RTEMS )
     2352    }, {
     2353      offsetof(
     2354        Configuration_Thread_control,
     2355        Control.libc_reent
     2356      ),
     2357      offsetof( Configuration_Thread_control, Newlib )
     2358    }
     2359    #ifdef RTEMS_POSIX_API
     2360      , {
     2361        offsetof(
     2362          Configuration_Thread_control,
     2363          Control.API_Extensions[ THREAD_API_POSIX ]
     2364        ),
     2365        offsetof( Configuration_Thread_control, API_POSIX )
     2366      }
     2367    #endif
     2368  };
     2369
     2370  const size_t _Thread_Control_add_on_count =
     2371    RTEMS_ARRAY_SIZE( _Thread_Control_add_ons );
     2372
    23832373  /**
    23842374   * This is the Classic API Configuration Table.
     
    25732563    uint32_t INTERRUPT_STACK_MEMORY;
    25742564    uint32_t MEMORY_FOR_IDLE_TASK;
    2575     uint32_t MEMORY_PER_TASK_FOR_SCHEDULER;
    25762565
    25772566    /* Classic API Pieces */
     
    26292618    CONFIGURE_INTERRUPT_STACK_MEMORY,
    26302619    CONFIGURE_MEMORY_FOR_IDLE_TASK,
    2631     CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER,
    26322620
    26332621    /* Classic API Pieces */
Note: See TracChangeset for help on using the changeset viewer.