Changeset d7665823 in rtems


Ignore:
Timestamp:
Jun 24, 2015, 1:43:19 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
e709aa85
Parents:
e273501
git-author:
Sebastian Huber <sebastian.huber@…> (06/24/15 13:43:19)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/23/15 06:01:13)
Message:

score: Introduce Thread_queue_Heads

Move the storage for the thread queue heads to the threads. Each thread
provides a set of thread queue heads allocated from a dedicated memory
pool. In case a thread blocks on a queue, then it lends its heads to
the queue. In case the thread unblocks, then it takes a free set of
threads from the queue. Since a thread can block on at most one queue
this works. This mechanism is used in FreeBSD. The motivation for this
change is to reduce the memory demands of the synchronization objects.
On a 32-bit uni-processor configuration the Thread_queue_Control size is
now 8 bytes, compared to 64 bytes in RTEMS 4.10 (other changes reduced
the size as well).

Files:
25 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/src/resource_snapshot.c

    re273501 rd7665823  
    6464  &_Region_Information,
    6565  &_Semaphore_Information,
    66   &_RTEMS_tasks_Information,
     66  &_RTEMS_tasks_Information.Objects,
    6767  &_Timer_Information
    6868  #ifdef RTEMS_POSIX_API
     
    7676    &_POSIX_Semaphore_Information,
    7777    &_POSIX_Spinlock_Information,
    78     &_POSIX_Threads_Information,
     78    &_POSIX_Threads_Information.Objects,
    7979    &_POSIX_Timer_Information
    8080  #endif
  • cpukit/libmisc/monitor/mon-object.c

    re273501 rd7665823  
    7676    },
    7777    { RTEMS_MONITOR_OBJECT_TASK,
    78       (void *) &_RTEMS_tasks_Information,
     78      (void *) &_RTEMS_tasks_Information.Objects,
    7979      sizeof(rtems_monitor_task_t),
    8080      (rtems_monitor_object_next_fn)        rtems_monitor_manager_next,
     
    133133#if defined(RTEMS_POSIX_API)
    134134    { RTEMS_MONITOR_OBJECT_PTHREAD,
    135       (void *) &_POSIX_Threads_Information,
     135      (void *) &_POSIX_Threads_Information.Objects,
    136136      sizeof(rtems_monitor_task_t),
    137137      (rtems_monitor_object_next_fn)        rtems_monitor_manager_next,
  • cpukit/posix/include/rtems/posix/pthreadimpl.h

    re273501 rd7665823  
    4545 * this class of objects.
    4646 */
    47 POSIX_EXTERN Objects_Information  _POSIX_Threads_Information;
     47POSIX_EXTERN Thread_Information  _POSIX_Threads_Information;
    4848
    4949/**
     
    172172
    173173  return (Thread_Control *)
    174     _Objects_Allocate_unprotected( &_POSIX_Threads_Information );
     174    _Objects_Allocate_unprotected( &_POSIX_Threads_Information.Objects );
    175175}
    176176
     
    201201)
    202202{
    203   _Objects_Free( &_POSIX_Threads_Information, &the_pthread->Object );
     203  _Objects_Free( &_POSIX_Threads_Information.Objects, &the_pthread->Object );
    204204}
    205205
  • cpukit/posix/src/killinfo.c

    re273501 rd7665823  
    7171  Thread_Control              *interested;
    7272  Priority_Control             interested_priority;
    73   Chain_Control               *the_chain;
    7473  Chain_Node                  *the_node;
    7574  siginfo_t                    siginfo_struct;
    7675  siginfo_t                   *siginfo;
    7776  POSIX_signals_Siginfo_node  *psiginfo;
     77  Thread_queue_Heads          *heads;
    7878
    7979  /*
     
    141141  /* XXX violation of visibility -- need to define thread queue support */
    142142
    143   the_chain = &_POSIX_signals_Wait_queue.Queue.Heads.Fifo;
    144 
    145   for ( the_node = _Chain_First( the_chain );
    146         !_Chain_Is_tail( the_chain, the_node ) ;
    147         the_node = the_node->next ) {
    148 
    149     the_thread = THREAD_CHAIN_NODE_TO_THREAD( the_node );
    150     api = the_thread->API_Extensions[ THREAD_API_POSIX ];
    151 
    152     #if defined(DEBUG_SIGNAL_PROCESSING)
    153       printk( "Waiting Thread=%p option=0x%08x mask=0x%08x blocked=0x%08x\n",
    154         the_thread, the_thread->Wait.option, mask, api->signals_blocked);
    155     #endif
    156 
    157     /*
    158      * Is this thread is actually blocked waiting for the signal?
    159      */
    160     if (the_thread->Wait.option & mask)
    161       goto process_it;
    162 
    163     /*
    164      * Is this thread is blocked waiting for another signal but has
    165      * not blocked this one?
    166      */
    167     if (~api->signals_blocked & mask)
    168       goto process_it;
     143  heads = _POSIX_signals_Wait_queue.Queue.heads;
     144  if ( heads != NULL ) {
     145    Chain_Control *the_chain = &heads->Heads.Fifo;
     146
     147    for ( the_node = _Chain_First( the_chain );
     148          !_Chain_Is_tail( the_chain, the_node ) ;
     149          the_node = the_node->next ) {
     150
     151      the_thread = THREAD_CHAIN_NODE_TO_THREAD( the_node );
     152      api = the_thread->API_Extensions[ THREAD_API_POSIX ];
     153
     154      #if defined(DEBUG_SIGNAL_PROCESSING)
     155        printk( "Waiting Thread=%p option=0x%08x mask=0x%08x blocked=0x%08x\n",
     156          the_thread, the_thread->Wait.option, mask, api->signals_blocked);
     157      #endif
     158
     159      /*
     160       * Is this thread is actually blocked waiting for the signal?
     161       */
     162      if (the_thread->Wait.option & mask)
     163        goto process_it;
     164
     165      /*
     166       * Is this thread is blocked waiting for another signal but has
     167       * not blocked this one?
     168       */
     169      if (~api->signals_blocked & mask)
     170        goto process_it;
     171    }
    169172  }
    170173
  • cpukit/posix/src/pthread.c

    re273501 rd7665823  
    371371  #endif
    372372
    373   _Objects_Initialize_information(
     373  _Thread_Initialize_information(
    374374    &_POSIX_Threads_Information, /* object information table */
    375375    OBJECTS_POSIX_API,           /* object API */
     
    377377    Configuration_POSIX_API.maximum_threads,
    378378                                 /* maximum objects of this class */
    379     _Thread_Control_size,        /* size of this object's control block */
    380379    true,                        /* true if names for this object are strings */
    381380    _POSIX_PATH_MAX              /* maximum length of each object's name */
    382381#if defined(RTEMS_MULTIPROCESSING)
    383382    ,
    384     false,                       /* true if this is a global object class */
    385     NULL                         /* Proxy extraction support callout */
     383    false                        /* true if this is a global object class */
    386384#endif
    387385  );
  • cpukit/rtems/include/rtems/rtems/tasksimpl.h

    re273501 rd7665823  
    5050 *  manage this class of objects.
    5151 */
    52 RTEMS_TASKS_EXTERN Objects_Information _RTEMS_tasks_Information;
     52RTEMS_TASKS_EXTERN Thread_Information _RTEMS_tasks_Information;
    5353
    5454/**
     
    8989
    9090  return (Thread_Control *)
    91     _Objects_Allocate_unprotected( &_RTEMS_tasks_Information );
     91    _Objects_Allocate_unprotected( &_RTEMS_tasks_Information.Objects );
    9292}
    9393
  • cpukit/rtems/src/taskcreate.c

    re273501 rd7665823  
    178178
    179179    _Objects_MP_Open(
    180       &_RTEMS_tasks_Information,
     180      &_RTEMS_tasks_Information.Objects,
    181181      the_global_object,
    182182      name,
  • cpukit/rtems/src/taskdelete.c

    re273501 rd7665823  
    3939      #if defined(RTEMS_MULTIPROCESSING)
    4040        if ( the_thread->is_global ) {
    41           _Objects_MP_Close( &_RTEMS_tasks_Information, the_thread->Object.id );
     41          _Objects_MP_Close(
     42            &_RTEMS_tasks_Information.Objects,
     43            the_thread->Object.id
     44          );
    4245          _RTEMS_tasks_MP_Send_process_packet(
    4346            RTEMS_TASKS_MP_ANNOUNCE_DELETE,
  • cpukit/rtems/src/taskident.c

    re273501 rd7665823  
    4545   }
    4646
    47   status = _Objects_Name_to_id_u32( &_RTEMS_tasks_Information, name, node, id );
     47  status = _Objects_Name_to_id_u32(
     48    &_RTEMS_tasks_Information.Objects,
     49    name,
     50    node,
     51    id
     52  );
    4853
    4954  return _Status_Object_name_errors_to_status[ status ];
  • cpukit/rtems/src/taskmp.c

    re273501 rd7665823  
    199199
    200200      ignored = _Objects_MP_Allocate_and_open(
    201                   &_RTEMS_tasks_Information,
     201                  &_RTEMS_tasks_Information.Objects,
    202202                  the_packet->name,
    203203                  the_packet->Prefix.id,
     
    210210    case RTEMS_TASKS_MP_ANNOUNCE_DELETE:
    211211
    212       _Objects_MP_Close( &_RTEMS_tasks_Information, the_packet->Prefix.id );
     212      _Objects_MP_Close(
     213        &_RTEMS_tasks_Information.Objects,
     214        the_packet->Prefix.id
     215      );
    213216
    214217      _MPCI_Return_packet( the_packet_prefix );
  • cpukit/rtems/src/tasks.c

    re273501 rd7665823  
    205205void _RTEMS_tasks_Manager_initialization(void)
    206206{
    207   _Objects_Initialize_information(
     207  _Thread_Initialize_information(
    208208    &_RTEMS_tasks_Information, /* object information table */
    209209    OBJECTS_CLASSIC_API,       /* object API */
     
    211211    Configuration_RTEMS_API.maximum_tasks,
    212212                               /* maximum objects of this class */
    213     _Thread_Control_size,      /* size of this object's control block */
    214213    false,                     /* true if the name is a string */
    215214    RTEMS_MAXIMUM_NAME_LENGTH  /* maximum length of an object name */
    216215#if defined(RTEMS_MULTIPROCESSING)
    217216    ,
    218     true,                      /* true if this is a global object class */
    219     NULL                       /* Proxy extraction support callout */
     217    true                       /* true if this is a global object class */
    220218#endif
    221219  );
  • cpukit/sapi/include/confdefs.h

    re273501 rd7665823  
    29702970  ( \
    29712971    _Configure_Object_RAM(_tasks, sizeof(Configuration_Thread_control)) \
     2972      + _Configure_From_workspace(_Configure_Max_Objects(_tasks) \
     2973        * sizeof(Thread_queue_Heads)) \
    29722974      + _Configure_Max_Objects(_number_FP_tasks) \
    29732975        * _Configure_From_workspace(CONTEXT_FP_SIZE) \
  • cpukit/score/include/rtems/score/objectimpl.h

    re273501 rd7665823  
    719719);
    720720
     721RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Extend_size(
     722  const Objects_Information *information
     723)
     724{
     725  return information->auto_extend ? information->allocation_size : 0;
     726}
     727
    721728/**
    722729 * This function returns true if the api is valid.
  • cpukit/score/include/rtems/score/thread.h

    re273501 rd7665823  
    350350   */
    351351  const Thread_queue_Operations *operations;
     352
     353  Thread_queue_Heads *spare_heads;
    352354}   Thread_Wait_information;
    353355
  • cpukit/score/include/rtems/score/threadimpl.h

    re273501 rd7665823  
    3333#include <rtems/score/threadqimpl.h>
    3434#include <rtems/score/todimpl.h>
     35#include <rtems/score/freechain.h>
    3536#include <rtems/config.h>
    3637
     
    5556SCORE_EXTERN void *rtems_ada_self;
    5657
     58typedef struct {
     59  Objects_Information Objects;
     60
     61  Freechain_Control Free_thread_queue_heads;
     62} Thread_Information;
     63
    5764/**
    5865 *  The following defines the information control block used to
    5966 *  manage this class of objects.
    6067 */
    61 SCORE_EXTERN Objects_Information _Thread_Internal_information;
     68SCORE_EXTERN Thread_Information _Thread_Internal_information;
    6269
    6370/**
     
    9097#endif
    9198
     99void _Thread_Initialize_information(
     100  Thread_Information  *information,
     101  Objects_APIs         the_api,
     102  uint16_t             the_class,
     103  uint32_t             maximum,
     104  bool                 is_string,
     105  uint32_t             maximum_name_length
     106#if defined(RTEMS_MULTIPROCESSING)
     107  ,
     108  bool                 supports_global
     109#endif
     110);
     111
    92112/**
    93113 *  @brief Initialize thread handler.
     
    155175 */
    156176bool _Thread_Initialize(
    157   Objects_Information                  *information,
     177  Thread_Information                   *information,
    158178  Thread_Control                       *the_thread,
    159179  const struct Scheduler_Control       *scheduler,
     
    737757{
    738758  return (Thread_Control *)
    739     _Objects_Allocate_unprotected( &_Thread_Internal_information );
     759    _Objects_Allocate_unprotected( &_Thread_Internal_information.Objects );
    740760}
    741761
  • cpukit/score/include/rtems/score/threadq.h

    re273501 rd7665823  
    5353  } Heads;
    5454
     55  Chain_Control Free_chain;
     56
     57  Chain_Node Free_node;
     58} Thread_queue_Heads;
     59
     60typedef struct {
     61  Thread_queue_Heads *heads;
     62
    5563  /**
    5664   * @brief Lock to protect this thread queue.
     
    8189
    8290/**
    83  * @brief Thread queue initialize operation.
    84  *
    85  * @param[in] queue The actual thread queue.
    86  *
    87  * @see _Thread_Wait_set_operations().
    88  */
    89 typedef void ( *Thread_queue_Initialize_operation )(
    90   Thread_queue_Queue *queue
    91 );
    92 
    93 /**
    9491 * @brief Thread queue enqueue operation.
    9592 *
     
    120117 * @brief Thread queue first operation.
    121118 *
    122  * @param[in] queue The actual thread queue.
     119 * @param[in] heads The thread queue heads.
    123120 *
    124121 * @retval NULL No thread is present on the thread queue.
     
    129126 */
    130127typedef Thread_Control *( *Thread_queue_First_operation )(
    131   Thread_queue_Queue *queue
     128  Thread_queue_Heads *heads
    132129);
    133130
     
    151148
    152149  /**
    153    * @brief Thread queue initialize operation.
    154    *
    155    * Called by object initialization routines.
    156    */
    157   Thread_queue_Initialize_operation initialize;
    158 
    159   /**
    160150   * @brief Thread queue enqueue operation.
    161151   *
  • cpukit/score/include/rtems/score/threadqimpl.h

    re273501 rd7665823  
    3333 */
    3434/**@{*/
     35
     36RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize(
     37  Thread_queue_Queue *queue
     38)
     39{
     40  queue->heads = NULL;
     41  _ISR_lock_Initialize( &queue->Lock, "Thread Queue" );
     42}
    3543
    3644RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_acquire_critical(
     
    323331)
    324332{
    325   return ( *the_thread_queue->operations->first )( &the_thread_queue->Queue );
     333  Thread_queue_Heads *heads = the_thread_queue->Queue.heads;
     334
     335  if ( heads != NULL ) {
     336    return ( *the_thread_queue->operations->first )( heads );
     337  } else {
     338    return NULL;
     339  }
    326340}
    327341
     
    376390  #define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \
    377391      .Queue = { \
    378         .Heads = { \
    379           .Fifo = CHAIN_INITIALIZER_EMPTY( designator.Queue.Heads.Fifo ) \
    380         }, \
     392        .heads = NULL, \
    381393        .Lock = ISR_LOCK_INITIALIZER( name ), \
    382394      }, \
     
    386398  #define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \
    387399      .Queue = { \
    388         .Heads = { \
    389           .Priority = RBTREE_INITIALIZER_EMPTY( \
    390             designator.Queue.Heads.Priority \
    391           ) \
    392         }, \
     400        .heads = NULL, \
    393401        .Lock = ISR_LOCK_INITIALIZER( name ), \
    394402      }, \
     
    397405#else
    398406  #define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \
    399       .Queue = { \
    400         .Heads = { \
    401           .Fifo = CHAIN_INITIALIZER_EMPTY( designator.Queue.Heads.Fifo ) \
    402         } \
    403       }, \
     407      .Queue = { .heads = NULL }, \
    404408      .operations = &_Thread_queue_Operations_FIFO \
    405409    }
    406410
    407411  #define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \
    408       .Queue = { \
    409         .Heads = { \
    410           .Priority = RBTREE_INITIALIZER_EMPTY( \
    411             designator.Queue.Heads.Priority \
    412           ) \
    413         } \
    414       }, \
     412      .Queue = { .heads = NULL }, \
    415413      .operations = &_Thread_queue_Operations_priority \
    416414    }
  • cpukit/score/src/thread.c

    re273501 rd7665823  
    2121#include <rtems/score/threadimpl.h>
    2222#include <rtems/score/interr.h>
     23#include <rtems/score/wkspace.h>
    2324
    2425#define THREAD_OFFSET_ASSERT( field ) \
     
    4041THREAD_OFFSET_ASSERT( receive_packet );
    4142#endif
     43
     44void _Thread_Initialize_information(
     45  Thread_Information  *information,
     46  Objects_APIs         the_api,
     47  uint16_t             the_class,
     48  uint32_t             maximum,
     49  bool                 is_string,
     50  uint32_t             maximum_name_length
     51#if defined(RTEMS_MULTIPROCESSING)
     52  ,
     53  bool                 supports_global
     54#endif
     55)
     56{
     57  _Objects_Initialize_information(
     58    &information->Objects,
     59    the_api,
     60    the_class,
     61    maximum,
     62    _Thread_Control_size,
     63    is_string,
     64    maximum_name_length
     65    #if defined(RTEMS_MULTIPROCESSING)
     66      ,
     67      supports_global,
     68      NULL
     69    #endif
     70  );
     71
     72  _Freechain_Initialize(
     73    &information->Free_thread_queue_heads,
     74    _Workspace_Allocate_or_fatal_error,
     75    _Objects_Maximum_per_allocation( maximum ),
     76    sizeof( Thread_queue_Heads )
     77  );
     78}
    4279
    4380void _Thread_Handler_initialization(void)
     
    70107   *  coupled multiprocessing system, account for the MPCI Server Thread.
    71108   */
    72   _Objects_Initialize_information(
     109  _Thread_Initialize_information(
    73110    &_Thread_Internal_information,
    74111    OBJECTS_INTERNAL_API,
    75112    OBJECTS_INTERNAL_THREADS,
    76113    _Thread_Get_maximum_internal_threads(),
    77     _Thread_Control_size,       /* size of this object's control block */
    78114    false,                      /* true if names for this object are strings */
    79115    8                           /* maximum length of each object's name */
    80116    #if defined(RTEMS_MULTIPROCESSING)
    81117      ,
    82       false,                      /* true if this is a global object class */
    83       NULL                        /* Proxy extraction support callout */
     118      false                       /* true if this is a global object class */
    84119    #endif
    85120  );
  • cpukit/score/src/threadinitialize.c

    re273501 rd7665823  
    3131
    3232bool _Thread_Initialize(
    33   Objects_Information                  *information,
     33  Thread_Information                   *information,
    3434  Thread_Control                       *the_thread,
    3535  const Scheduler_Control              *scheduler,
     
    7777
    7878  the_thread->Start.tls_area = NULL;
     79  the_thread->Wait.spare_heads = NULL;
    7980
    8081  /*
     
    134135    the_thread->Start.fp_context = fp_area;
    135136  #endif
     137
     138  /*
     139   *  Get thread queue heads
     140   */
     141  the_thread->Wait.spare_heads = _Freechain_Get(
     142    &information->Free_thread_queue_heads,
     143    _Workspace_Allocate,
     144    _Objects_Extend_size( &information->Objects ),
     145    sizeof( *the_thread->Wait.spare_heads )
     146  );
     147  if ( the_thread->Wait.spare_heads == NULL ) {
     148    goto failed;
     149  }
     150  _Chain_Initialize_empty( &the_thread->Wait.spare_heads->Free_chain );
    136151
    137152  /*
     
    240255   *  Open the object
    241256   */
    242   _Objects_Open( information, &the_thread->Object, name );
     257  _Objects_Open( &information->Objects, &the_thread->Object, name );
    243258
    244259  /*
     
    261276  _Workspace_Free( the_thread->Start.tls_area );
    262277
     278  _Freechain_Put(
     279    &information->Free_thread_queue_heads,
     280    the_thread->Wait.spare_heads
     281  );
     282
    263283  #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
    264284    _Workspace_Free( fp_area );
  • cpukit/score/src/threadq.c

    re273501 rd7665823  
    5151  const Thread_queue_Operations *operations;
    5252
    53   _ISR_lock_Initialize( &the_thread_queue->Queue.Lock, "Thread Queue" );
    54 
    5553  if ( the_discipline == THREAD_QUEUE_DISCIPLINE_PRIORITY ) {
    5654    operations = &_Thread_queue_Operations_priority;
     
    6159
    6260  the_thread_queue->operations = operations;
    63   ( *operations->initialize )( &the_thread_queue->Queue );
     61
     62  _Thread_queue_Queue_initialize( &the_thread_queue->Queue );
    6463}
  • cpukit/score/src/threadqops.c

    re273501 rd7665823  
    1818
    1919#include <rtems/score/threadimpl.h>
     20#include <rtems/score/assert.h>
    2021#include <rtems/score/chainimpl.h>
    2122#include <rtems/score/rbtreeimpl.h>
     
    3839}
    3940
    40 static void _Thread_queue_FIFO_initialize(
    41   Thread_queue_Queue *queue
    42 )
    43 {
    44   _Chain_Initialize_empty( &queue->Heads.Fifo );
     41static void _Thread_queue_Queue_enqueue(
     42  Thread_queue_Queue *queue,
     43  Thread_Control     *the_thread,
     44  void             ( *initialize )( Thread_queue_Heads * ),
     45  void             ( *enqueue )( Thread_queue_Heads *, Thread_Control * )
     46)
     47{
     48  Thread_queue_Heads *heads = queue->heads;
     49  Thread_queue_Heads *spare_heads = the_thread->Wait.spare_heads;
     50
     51  the_thread->Wait.spare_heads = NULL;
     52
     53  if ( heads == NULL ) {
     54    _Assert( spare_heads != NULL );
     55    _Assert( _Chain_Is_empty( &spare_heads->Free_chain ) );
     56    heads = spare_heads;
     57    queue->heads = heads;
     58    ( *initialize )( heads );
     59  }
     60
     61  _Chain_Prepend_unprotected( &heads->Free_chain, &spare_heads->Free_node );
     62
     63  ( *enqueue )( heads, the_thread );
     64}
     65
     66static void _Thread_queue_Queue_extract(
     67  Thread_queue_Queue *queue,
     68  Thread_Control     *the_thread,
     69  void             ( *extract )( Thread_queue_Heads *, Thread_Control * )
     70)
     71{
     72  Thread_queue_Heads *heads = queue->heads;
     73
     74  _Assert( heads != NULL );
     75
     76  the_thread->Wait.spare_heads = RTEMS_CONTAINER_OF(
     77    _Chain_Get_first_unprotected( &heads->Free_chain ),
     78    Thread_queue_Heads,
     79    Free_node
     80  );
     81
     82  if ( _Chain_Is_empty( &heads->Free_chain ) ) {
     83    queue->heads = NULL;
     84  }
     85
     86  ( *extract )( heads, the_thread );
     87}
     88
     89static void _Thread_queue_FIFO_do_initialize(
     90  Thread_queue_Heads *heads
     91)
     92{
     93  _Chain_Initialize_empty( &heads->Heads.Fifo );
     94}
     95
     96static void _Thread_queue_FIFO_do_enqueue(
     97  Thread_queue_Heads *heads,
     98  Thread_Control     *the_thread
     99)
     100{
     101  _Chain_Append_unprotected(
     102    &heads->Heads.Fifo,
     103    &the_thread->Wait.Node.Chain
     104  );
     105}
     106
     107static void _Thread_queue_FIFO_do_extract(
     108  Thread_queue_Heads *heads,
     109  Thread_Control     *the_thread
     110)
     111{
     112  _Chain_Extract_unprotected( &the_thread->Wait.Node.Chain );
    45113}
    46114
     
    50118)
    51119{
    52   _Chain_Append_unprotected(
    53     &queue->Heads.Fifo,
    54     &the_thread->Wait.Node.Chain
     120  _Thread_queue_Queue_enqueue(
     121    queue,
     122    the_thread,
     123    _Thread_queue_FIFO_do_initialize,
     124    _Thread_queue_FIFO_do_enqueue
    55125  );
    56126}
     
    61131)
    62132{
    63   _Chain_Extract_unprotected( &the_thread->Wait.Node.Chain );
     133  _Thread_queue_Queue_extract(
     134    queue,
     135    the_thread,
     136    _Thread_queue_FIFO_do_extract
     137  );
    64138}
    65139
    66140static Thread_Control *_Thread_queue_FIFO_first(
    67   Thread_queue_Queue *queue
    68 )
    69 {
    70   Chain_Control *fifo = &queue->Heads.Fifo;
     141  Thread_queue_Heads *heads
     142)
     143{
     144  Chain_Control *fifo = &heads->Heads.Fifo;
    71145
    72146  return _Chain_Is_empty( fifo ) ?
     
    80154)
    81155{
     156  Thread_queue_Heads *heads = queue->heads;
     157
     158  _Assert( heads != NULL );
     159
    82160  _RBTree_Extract(
    83     &queue->Heads.Priority,
     161    &heads->Heads.Priority,
    84162    &the_thread->Wait.Node.RBTree
    85163  );
    86164  _RBTree_Insert(
    87     &queue->Heads.Priority,
     165    &heads->Heads.Priority,
    88166    &the_thread->Wait.Node.RBTree,
    89167    _Thread_queue_Compare_priority,
     
    92170}
    93171
    94 static void _Thread_queue_Priority_initialize(
    95   Thread_queue_Queue *queue
    96 )
    97 {
    98   _RBTree_Initialize_empty( &queue->Heads.Priority );
    99 }
    100 
    101 static void _Thread_queue_Priority_enqueue(
    102   Thread_queue_Queue *queue,
     172static void _Thread_queue_Priority_do_initialize(
     173  Thread_queue_Heads *heads
     174)
     175{
     176  _RBTree_Initialize_empty( &heads->Heads.Priority );
     177}
     178
     179static void _Thread_queue_Priority_do_enqueue(
     180  Thread_queue_Heads *heads,
    103181  Thread_Control     *the_thread
    104182)
    105183{
    106184  _RBTree_Insert(
    107     &queue->Heads.Priority,
     185    &heads->Heads.Priority,
    108186    &the_thread->Wait.Node.RBTree,
    109187    _Thread_queue_Compare_priority,
     
    112190}
    113191
     192static void _Thread_queue_Priority_do_extract(
     193  Thread_queue_Heads *heads,
     194  Thread_Control     *the_thread
     195)
     196{
     197  _RBTree_Extract(
     198    &heads->Heads.Priority,
     199    &the_thread->Wait.Node.RBTree
     200  );
     201}
     202
     203static void _Thread_queue_Priority_enqueue(
     204  Thread_queue_Queue *queue,
     205  Thread_Control     *the_thread
     206)
     207{
     208  _Thread_queue_Queue_enqueue(
     209    queue,
     210    the_thread,
     211    _Thread_queue_Priority_do_initialize,
     212    _Thread_queue_Priority_do_enqueue
     213  );
     214}
     215
    114216static void _Thread_queue_Priority_extract(
    115217  Thread_queue_Queue *queue,
     
    117219)
    118220{
    119   _RBTree_Extract(
    120     &queue->Heads.Priority,
    121     &the_thread->Wait.Node.RBTree
     221  _Thread_queue_Queue_extract(
     222    queue,
     223    the_thread,
     224    _Thread_queue_Priority_do_extract
    122225  );
    123226}
    124227
    125228static Thread_Control *_Thread_queue_Priority_first(
    126   Thread_queue_Queue *queue
     229  Thread_queue_Heads *heads
    127230)
    128231{
    129232  RBTree_Node *first;
    130233
    131   first = _RBTree_First( &queue->Heads.Priority, RBT_LEFT );
     234  first = _RBTree_First( &heads->Heads.Priority, RBT_LEFT );
    132235
    133236  return first != NULL ? THREAD_RBTREE_NODE_TO_THREAD( first ) : NULL;
     
    146249const Thread_queue_Operations _Thread_queue_Operations_FIFO = {
    147250  .priority_change = _Thread_queue_Do_nothing_priority_change,
    148   .initialize = _Thread_queue_FIFO_initialize,
    149251  .enqueue = _Thread_queue_FIFO_enqueue,
    150252  .extract = _Thread_queue_FIFO_extract,
     
    154256const Thread_queue_Operations _Thread_queue_Operations_priority = {
    155257  .priority_change = _Thread_queue_Priority_priority_change,
    156   .initialize = _Thread_queue_Priority_initialize,
    157258  .enqueue = _Thread_queue_Priority_enqueue,
    158259  .extract = _Thread_queue_Priority_extract,
  • cpukit/score/src/threadrestart.c

    re273501 rd7665823  
    9494static void _Thread_Free( Thread_Control *the_thread )
    9595{
     96  Thread_Information *information = (Thread_Information *)
     97    _Objects_Get_information_id( the_thread->Object.id );
     98
    9699  _User_extensions_Thread_delete( the_thread );
    97100
     
    113116#endif
    114117
     118  _Freechain_Put(
     119    &information->Free_thread_queue_heads,
     120    the_thread->Wait.spare_heads
     121  );
     122
    115123  /*
    116124   *  Free the rest of the memory associated with this task
     
    125133#endif
    126134
    127   _Objects_Free(
    128     _Objects_Get_information_id( the_thread->Object.id ),
    129     &the_thread->Object
    130   );
     135  _Objects_Free( &information->Objects, &the_thread->Object );
    131136}
    132137
  • testsuites/sptests/spobjgetnext/init.c

    re273501 rd7665823  
    7676  TEST_BEGIN();
    7777
    78   info      = &_RTEMS_tasks_Information;
     78  info      = &_RTEMS_tasks_Information.Objects;
    7979  main_task = rtems_task_self();
    8080
  • testsuites/sptests/sptask_err04/task1.c

    re273501 rd7665823  
    100100
    101101    status = rtems_task_get_note(
    102       _RTEMS_tasks_Information.minimum_id + (3L<<OBJECTS_API_START_BIT),
     102      _RTEMS_tasks_Information.Objects.minimum_id + (3L<<OBJECTS_API_START_BIT),
    103103      RTEMS_NOTEPAD_LAST,
    104104      &notepad_value
  • testsuites/sptests/spthreadq01/init.c

    re273501 rd7665823  
    3737  /* is there more to check? */
    3838
    39   rtems_test_assert( _Chain_Is_empty( &fifo_queue.Queue.Heads.Fifo ) );
     39  rtems_test_assert( fifo_queue.Queue.heads == NULL );
    4040  rtems_test_assert( fifo_queue.operations == &_Thread_queue_Operations_FIFO );
    4141
    42   rtems_test_assert( _RBTree_Is_empty( &fifo_queue.Queue.Heads.Priority ) );
     42  rtems_test_assert( prio_queue.Queue.heads == NULL );
    4343  rtems_test_assert(
    4444    prio_queue.operations == &_Thread_queue_Operations_priority
Note: See TracChangeset for help on using the changeset viewer.