RTEMS  5.1
threadqimpl.h
Go to the documentation of this file.
1 
12 /*
13  * COPYRIGHT (c) 1989-2014.
14  * On-Line Applications Research Corporation (OAR).
15  *
16  * The license and distribution terms for this file may be
17  * found in the file LICENSE in this distribution or at
18  * http://www.rtems.org/license/LICENSE.
19  */
20 
21 #ifndef _RTEMS_SCORE_THREADQIMPL_H
22 #define _RTEMS_SCORE_THREADQIMPL_H
23 
24 #include <rtems/score/threadq.h>
25 #include <rtems/score/chainimpl.h>
27 #include <rtems/score/scheduler.h>
28 #include <rtems/score/smp.h>
29 #include <rtems/score/status.h>
30 #include <rtems/score/thread.h>
32 
33 #if defined(RTEMS_DEBUG)
34 #include <string.h>
35 #endif
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
47 #define THREAD_QUEUE_LINK_OF_PATH_NODE( node ) \
48  RTEMS_CONTAINER_OF( node, Thread_queue_Link, Path_node );
49 
54 typedef struct {
55 #if !defined(RTEMS_SMP)
56  /*
57  * The struct _Thread_queue_Queue definition is independent of the RTEMS
58  * build configuration. Thus, the storage space for the SMP lock is always
59  * present. In SMP configurations, the SMP lock is contained in the
60  * Thread_queue_Queue.
61  */
62  unsigned int reserved[2];
63 #endif
64 
65  Thread_queue_Queue Queue;
67 
77  Thread_queue_Queue *queue,
78  Thread_Control *the_thread,
79  Per_CPU_Control *cpu_self,
80  Thread_queue_Context *queue_context
81 );
82 
92  Thread_queue_Queue *queue,
93  Thread_Control *the_thread,
94  Per_CPU_Control *cpu_self,
95  Thread_queue_Context *queue_context
96 );
97 
109  Thread_queue_Queue *queue,
110  Thread_Control *the_thread,
111  Per_CPU_Control *cpu_self,
112  Thread_queue_Context *queue_context
113 );
114 
126  Thread_queue_Queue *queue,
127  Thread_Control *the_thread,
128  Per_CPU_Control *cpu_self,
129  Thread_queue_Context *queue_context
130 );
131 
139 
145 void _Thread_queue_Deadlock_fatal( Thread_Control *the_thread );
146 
153  Thread_queue_Context *queue_context
154 )
155 {
156 #if defined(RTEMS_DEBUG)
157  memset( queue_context, 0x7f, sizeof( *queue_context ) );
158 #if defined(RTEMS_SMP)
159  _Chain_Initialize_node( &queue_context->Lock_context.Wait.Gate.Node );
160 #endif
161  queue_context->enqueue_callout = NULL;
162  queue_context->deadlock_callout = NULL;
163 #else
164  (void) queue_context;
165 #endif
166 }
167 
179  Thread_queue_Context *queue_context,
180  States_Control thread_state
181 )
182 {
183  queue_context->thread_state = thread_state;
184 }
185 
196  Thread_queue_Context *queue_context,
197  Watchdog_Interval ticks
198 )
199 {
200  queue_context->Timeout.ticks = ticks;
201 }
202 
213  Thread_queue_Context *queue_context,
214  const void *arg
215 )
216 {
217  queue_context->Timeout.arg = arg;
218 }
219 
230  Thread_queue_Context *queue_context,
231  Thread_queue_Enqueue_callout enqueue_callout
232 )
233 {
234  queue_context->enqueue_callout = enqueue_callout;
235 }
236 
246  Thread_queue_Context *queue_context
247 )
248 {
250 }
251 
263  Thread_queue_Context *queue_context,
264  Watchdog_Interval ticks
265 )
266 {
267  queue_context->Timeout.ticks = ticks;
269 }
270 
282  Thread_queue_Context *queue_context,
283  const struct timespec *abstime
284 )
285 {
286  queue_context->Timeout.arg = abstime;
287  queue_context->enqueue_callout =
289 }
290 
302  Thread_queue_Context *queue_context,
303  const struct timespec *abstime
304 )
305 {
306  queue_context->Timeout.arg = abstime;
308 }
309 
325  Thread_queue_Context *queue_context,
326  Thread_queue_Deadlock_callout deadlock_callout
327 )
328 {
329  queue_context->deadlock_callout = deadlock_callout;
330 }
331 
339  Thread_queue_Context *queue_context
340 )
341 {
342  queue_context->Priority.update_count = 0;
343 }
344 
354  Thread_queue_Context *queue_context
355 )
356 {
357  return queue_context->Priority.update_count;
358 }
359 
368  Thread_queue_Context *queue_context,
369  size_t update_count
370 )
371 {
372  queue_context->Priority.update_count = update_count;
373 }
374 
384  Thread_queue_Context *queue_context,
385  Thread_Control *the_thread
386 )
387 {
388  size_t n;
389 
390  n = queue_context->Priority.update_count;
391  _Assert( n < RTEMS_ARRAY_SIZE( queue_context->Priority.update ) );
392 
393  queue_context->Priority.update_count = n + 1;
394  queue_context->Priority.update[ n ] = the_thread;
395 }
396 
397 #define _Thread_queue_Context_ISR_disable( queue_context, level ) \
398  do { \
399  _ISR_Local_disable( level ); \
400  _ISR_lock_ISR_disable_profile( \
401  &( queue_context )->Lock_context.Lock_context \
402  ) \
403  } while ( 0 )
404 
412  Thread_queue_Context *queue_context,
413  ISR_Level level
414 )
415 {
417  &queue_context->Lock_context.Lock_context,
418  level
419  );
420 }
421 
430  Thread_queue_Context *queue_context
431 )
432 {
434  &queue_context->Lock_context.Lock_context
435  );
436 }
437 
447 #if defined(RTEMS_MULTIPROCESSING)
449  Thread_queue_Context *queue_context,
450  Thread_queue_MP_callout mp_callout
451 )
452 {
453  queue_context->mp_callout = mp_callout;
454 }
455 #else
456 #define _Thread_queue_Context_set_MP_callout( queue_context, mp_callout ) \
457  do { \
458  (void) queue_context; \
459  } while ( 0 )
460 #endif
461 
462 #if defined(RTEMS_SMP)
463 
468 RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_close(
469  Thread_queue_Gate *gate
470 )
471 {
472  _Atomic_Store_uint( &gate->go_ahead, 0, ATOMIC_ORDER_RELAXED );
473 }
474 
481 RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_add(
482  Chain_Control *chain,
483  Thread_queue_Gate *gate
484 )
485 {
486  _Chain_Append_unprotected( chain, &gate->Node );
487 }
488 
494 RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_open(
495  Thread_queue_Gate *gate
496 )
497 {
498  _Atomic_Store_uint( &gate->go_ahead, 1, ATOMIC_ORDER_RELAXED );
499 }
500 
508 RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_wait(
509  Thread_queue_Gate *gate
510 )
511 {
512  while ( _Atomic_Load_uint( &gate->go_ahead, ATOMIC_ORDER_RELAXED ) == 0 ) {
513  /* Wait */
514  }
515 }
516 #endif
517 
524  Thread_queue_Heads *heads
525 )
526 {
527 #if defined(RTEMS_SMP)
528  size_t i;
529 
530  for ( i = 0; i < _Scheduler_Count; ++i ) {
531  _Chain_Initialize_node( &heads->Priority[ i ].Node );
532  _Priority_Initialize_empty( &heads->Priority[ i ].Queue );
533  heads->Priority[ i ].Queue.scheduler = &_Scheduler_Table[ i ];
534  }
535 #endif
536 
539 }
540 
548  Thread_queue_Queue *queue,
549  const char *name
550 )
551 {
552 #if defined(RTEMS_SMP)
553  _SMP_ticket_lock_Initialize( &queue->Lock );
554 #endif
555  queue->heads = NULL;
556  queue->owner = NULL;
557  queue->name = name;
558 }
559 
568  Thread_queue_Queue *queue,
569 #if defined(RTEMS_SMP) && defined(RTEMS_PROFILING)
570  SMP_lock_Stats *lock_stats,
571 #endif
572  ISR_lock_Context *lock_context
573 )
574 {
575 #if defined(RTEMS_SMP)
576  _SMP_ticket_lock_Acquire(
577  &queue->Lock,
578  lock_stats,
579  &lock_context->Lock_context.Stats_context
580  );
581 #else
582  (void) queue;
583  (void) lock_context;
584 #endif
585 }
586 
587 #if defined(RTEMS_SMP) && defined( RTEMS_PROFILING )
588  #define \
589  _Thread_queue_Queue_acquire_critical( queue, lock_stats, lock_context ) \
590  _Thread_queue_Queue_do_acquire_critical( queue, lock_stats, lock_context )
591 #else
592  #define \
593  _Thread_queue_Queue_acquire_critical( queue, lock_stats, lock_context ) \
594  _Thread_queue_Queue_do_acquire_critical( queue, lock_context )
595 #endif
596 
604  Thread_queue_Queue *queue,
605  ISR_lock_Context *lock_context
606 )
607 {
608 #if defined(RTEMS_SMP)
609  _SMP_ticket_lock_Release(
610  &queue->Lock,
611  &lock_context->Lock_context.Stats_context
612  );
613 #else
614  (void) queue;
615  (void) lock_context;
616 #endif
617 }
618 
626  Thread_queue_Queue *queue,
627  ISR_lock_Context *lock_context
628 )
629 {
630  _Thread_queue_Queue_release_critical( queue, lock_context );
631  _ISR_lock_ISR_enable( lock_context );
632 }
633 
647  const Thread_queue_Queue *queue,
648  char *buffer,
649  size_t buffer_size,
650  Objects_Id *id
651 );
652 
659 #if defined(RTEMS_SMP)
661  Thread_queue_Control *the_thread_queue,
662  ISR_lock_Context *lock_context
663 );
664 #else
666  Thread_queue_Control *the_thread_queue,
667  ISR_lock_Context *lock_context
668 )
669 {
670  (void) the_thread_queue;
671  (void) lock_context;
672 }
673 #endif
674 
682  Thread_queue_Control *the_thread_queue,
683  Thread_queue_Context *queue_context
684 )
685 {
687  the_thread_queue,
688  &queue_context->Lock_context.Lock_context
689  );
690 }
691 
698 #if defined(RTEMS_SMP)
700  Thread_queue_Control *the_thread_queue,
701  Thread_queue_Context *queue_context
702 );
703 #else
705  Thread_queue_Control *the_thread_queue,
706  Thread_queue_Context *queue_context
707 )
708 {
709  (void) the_thread_queue;
711 }
712 #endif
713 
722 #if defined(RTEMS_DEBUG)
723 RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_lock_owner(
724  const Thread_queue_Control *the_thread_queue
725 )
726 {
727 #if defined(RTEMS_SMP)
728  return the_thread_queue->owner == _SMP_lock_Who_am_I();
729 #else
730  return _ISR_Get_level() != 0;
731 #endif
732 }
733 #endif
734 
741 #if defined(RTEMS_SMP)
743  Thread_queue_Control *the_thread_queue,
744  ISR_lock_Context *lock_context
745 );
746 #else
748  Thread_queue_Control *the_thread_queue,
749  ISR_lock_Context *lock_context
750 )
751 {
752  (void) the_thread_queue;
753  (void) lock_context;
754  _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) );
755 }
756 #endif
757 
765  Thread_queue_Control *the_thread_queue,
766  Thread_queue_Context *queue_context
767 )
768 {
770  the_thread_queue,
771  &queue_context->Lock_context.Lock_context
772  );
773 }
774 
781 #if defined(RTEMS_SMP)
783  Thread_queue_Control *the_thread_queue,
784  Thread_queue_Context *queue_context
785 );
786 #else
788  Thread_queue_Control *the_thread_queue,
789  Thread_queue_Context *queue_context
790 )
791 {
792  (void) the_thread_queue;
793  _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) );
795 }
796 #endif
797 
807  Thread_queue_Control *the_thread_queue,
808  const Thread_queue_Operations *operations
809 #if defined(RTEMS_MULTIPROCESSING)
810  ,
811  Thread_queue_MP_callout mp_callout
812 #endif
813 );
814 
826 #if defined(RTEMS_MULTIPROCESSING)
827  #define _Thread_queue_Dequeue( \
828  the_thread_queue, \
829  operations, \
830  mp_callout \
831  ) \
832  _Thread_queue_Do_dequeue( \
833  the_thread_queue, \
834  operations, \
835  mp_callout \
836  )
837 #else
838  #define _Thread_queue_Dequeue( \
839  the_thread_queue, \
840  operations, \
841  mp_callout \
842  ) \
843  _Thread_queue_Do_dequeue( \
844  the_thread_queue, \
845  operations \
846  )
847 #endif
848 
927  Thread_queue_Queue *queue,
928  const Thread_queue_Operations *operations,
929  Thread_Control *the_thread,
930  Thread_queue_Context *queue_context
931 );
932 
933 #if defined(RTEMS_SMP)
934 
956 Status_Control _Thread_queue_Enqueue_sticky(
957  Thread_queue_Queue *queue,
958  const Thread_queue_Operations *operations,
959  Thread_Control *the_thread,
960  Thread_queue_Context *queue_context
961 );
962 #endif
963 
985  Thread_queue_Queue *queue,
986  const Thread_queue_Operations *operations,
987  Thread_Control *the_thread,
988  Thread_queue_Context *queue_context
989 );
990 
1006  bool unblock,
1007  Thread_queue_Queue *queue,
1008  Thread_Control *the_thread,
1009  ISR_lock_Context *lock_context
1010 );
1011 
1059  Thread_queue_Queue *queue,
1060  const Thread_queue_Operations *operations,
1061  Thread_Control *the_thread,
1062  Thread_queue_Context *queue_context
1063 );
1064 
1074 void _Thread_queue_Extract( Thread_Control *the_thread );
1075 
1087  Thread_Control *the_thread
1088 );
1089 
1107  Thread_queue_Queue *queue,
1108  Thread_queue_Heads *heads,
1109  Thread_Control *previous_owner,
1110  Thread_queue_Context *queue_context,
1111  const Thread_queue_Operations *operations
1112 );
1113 
1114 #if defined(RTEMS_SMP)
1115 
1135 void _Thread_queue_Surrender_sticky(
1136  Thread_queue_Queue *queue,
1137  Thread_queue_Heads *heads,
1138  Thread_Control *previous_owner,
1139  Thread_queue_Context *queue_context,
1140  const Thread_queue_Operations *operations
1141 );
1142 #endif
1143 
1153  const Thread_queue_Queue *queue
1154 )
1155 {
1156  return queue->heads == NULL;
1157 }
1158 
1174  Thread_queue_Control *the_thread_queue,
1175  const Thread_queue_Operations *operations
1176 )
1177 {
1178  Thread_queue_Heads *heads = the_thread_queue->Queue.heads;
1179 
1180  if ( heads != NULL ) {
1181  return ( *operations->first )( heads );
1182  } else {
1183  return NULL;
1184  }
1185 }
1186 
1198  Thread_queue_Control *the_thread_queue,
1199  const Thread_queue_Operations *operations
1200 );
1201 
1223 typedef Thread_Control *( *Thread_queue_Flush_filter )(
1224  Thread_Control *the_thread,
1225  Thread_queue_Queue *queue,
1226  Thread_queue_Context *queue_context
1227 );
1228 
1239  Thread_Control *the_thread,
1240  Thread_queue_Queue *queue,
1241  Thread_queue_Context *queue_context
1242 );
1243 
1256  Thread_Control *the_thread,
1257  Thread_queue_Queue *queue,
1258  Thread_queue_Context *queue_context
1259 );
1260 
1273  Thread_Control *the_thread,
1274  Thread_queue_Queue *queue,
1275  Thread_queue_Context *queue_context
1276 );
1277 
1301  Thread_queue_Queue *queue,
1302  const Thread_queue_Operations *operations,
1304  Thread_queue_Context *queue_context
1305 );
1306 
1314  Thread_queue_Control *the_thread_queue,
1315  const char *name
1316 );
1317 
1318 #if defined(RTEMS_SMP) && defined(RTEMS_DEBUG) && defined(RTEMS_PROFILING)
1319  #define THREAD_QUEUE_INITIALIZER( _name ) \
1320  { \
1321  .Lock_stats = SMP_LOCK_STATS_INITIALIZER( _name ), \
1322  .owner = SMP_LOCK_NO_OWNER, \
1323  .Queue = { \
1324  .Lock = SMP_TICKET_LOCK_INITIALIZER, \
1325  .heads = NULL, \
1326  .owner = NULL, \
1327  .name = _name \
1328  } \
1329  }
1330 #elif defined(RTEMS_SMP) && defined(RTEMS_DEBUG)
1331  #define THREAD_QUEUE_INITIALIZER( _name ) \
1332  { \
1333  .owner = SMP_LOCK_NO_OWNER, \
1334  .Queue = { \
1335  .Lock = SMP_TICKET_LOCK_INITIALIZER, \
1336  .heads = NULL, \
1337  .owner = NULL, \
1338  .name = _name \
1339  } \
1340  }
1341 #elif defined(RTEMS_SMP) && defined(RTEMS_PROFILING)
1342  #define THREAD_QUEUE_INITIALIZER( _name ) \
1343  { \
1344  .Lock_stats = SMP_LOCK_STATS_INITIALIZER( _name ), \
1345  .Queue = { \
1346  .Lock = SMP_TICKET_LOCK_INITIALIZER, \
1347  .heads = NULL, \
1348  .owner = NULL, \
1349  .name = _name \
1350  } \
1351  }
1352 #elif defined(RTEMS_SMP)
1353  #define THREAD_QUEUE_INITIALIZER( _name ) \
1354  { \
1355  .Queue = { \
1356  .Lock = SMP_TICKET_LOCK_INITIALIZER, \
1357  .heads = NULL, \
1358  .owner = NULL, \
1359  .name = _name \
1360  } \
1361  }
1362 #else
1363  #define THREAD_QUEUE_INITIALIZER( _name ) \
1364  { \
1365  .Queue = { \
1366  .heads = NULL, \
1367  .owner = NULL, \
1368  .name = _name \
1369  } \
1370  }
1371 #endif
1372 
1379  Thread_queue_Control *the_thread_queue
1380 )
1381 {
1382 #if defined(RTEMS_SMP)
1383  _SMP_ticket_lock_Destroy( &the_thread_queue->Queue.Lock );
1384  _SMP_lock_Stats_destroy( &the_thread_queue->Lock_stats );
1385 #endif
1386 }
1387 
1394 #if defined(RTEMS_MULTIPROCESSING)
1395 void _Thread_queue_MP_callout_do_nothing(
1396  Thread_Control *the_proxy,
1397  Objects_Id mp_id
1398 );
1399 
1406 void _Thread_queue_Unblock_proxy(
1407  Thread_queue_Queue *queue,
1408  Thread_Control *the_thread
1409 );
1410 #endif
1411 
1422 #if defined(RTEMS_SMP)
1423 bool _Thread_queue_Path_acquire_critical(
1424  Thread_queue_Queue *queue,
1425  Thread_Control *the_thread,
1426  Thread_queue_Context *queue_context
1427 );
1428 
1434 void _Thread_queue_Path_release_critical(
1435  Thread_queue_Context *queue_context
1436 );
1437 #endif
1438 
1445 typedef struct {
1446  Objects_Control Object;
1447  Thread_queue_Control Wait_queue;
1449 
1450 #define THREAD_QUEUE_OBJECT_ASSERT( object_type, wait_queue_member, msg ) \
1451  RTEMS_STATIC_ASSERT( \
1452  offsetof( object_type, wait_queue_member ) \
1453  == offsetof( Thread_queue_Object, Wait_queue ) \
1454  && RTEMS_HAVE_MEMBER_SAME_TYPE( \
1455  object_type, \
1456  wait_queue_member, \
1457  Thread_queue_Object, \
1458  Wait_queue \
1459  ), \
1460  msg \
1461  )
1462 
1463 #define THREAD_QUEUE_QUEUE_TO_OBJECT( queue ) \
1464  RTEMS_CONTAINER_OF( \
1465  queue, \
1466  Thread_queue_Object, \
1467  Wait_queue.Queue \
1468  )
1469 
1470 extern const Thread_queue_Operations _Thread_queue_Operations_default;
1471 
1472 extern const Thread_queue_Operations _Thread_queue_Operations_FIFO;
1473 
1474 extern const Thread_queue_Operations _Thread_queue_Operations_priority;
1475 
1476 extern const Thread_queue_Operations _Thread_queue_Operations_priority_inherit;
1477 
1484 extern const char _Thread_queue_Object_name[];
1485 
1495  Thread_queue_Control *the_thread_queue
1496 );
1497 
1500 #ifdef __cplusplus
1501 }
1502 #endif
1503 
1504 #endif
1505 /* end of include file */
Watchdog_Interval ticks
The timeout in ticks.
Definition: threadq.h:232
Thread_Control * owner
The thread queue owner.
Definition: threadq.h:431
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_enqueue_timeout_monotonic_timespec(Thread_queue_Context *queue_context, const struct timespec *abstime)
Sets the enqueue callout to add an absolute monotonic timeout in timespec format.
Definition: threadqimpl.h:281
void(* Thread_queue_Deadlock_callout)(Thread_Control *the_thread)
Thread queue deadlock callout.
Definition: threadq.h:86
RTEMS_INLINE_ROUTINE Per_CPU_Control * _Thread_queue_Dispatch_disable(Thread_queue_Context *queue_context)
Disables dispatching in a critical section.
Definition: threadqimpl.h:429
RTEMS_INLINE_ROUTINE Per_CPU_Control * _Thread_Dispatch_disable_critical(const ISR_lock_Context *lock_context)
Disables thread dispatching inside a critical section (interrupts disabled).
Definition: threaddispatch.h:179
RTEMS_INLINE_ROUTINE void _Chain_Initialize_node(Chain_Node *the_node)
Initializes a chain node.
Definition: chainimpl.h:122
RTEMS_INLINE_ROUTINE Thread_Control * _Thread_queue_First_locked(Thread_queue_Control *the_thread_queue, const Thread_queue_Operations *operations)
Returns the first thread on the thread queue if it exists, otherwise NULL.
Definition: threadqimpl.h:1173
Definition: objectdata.h:39
RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release_critical(Thread_queue_Queue *queue, ISR_lock_Context *lock_context)
Releases the thread queue queue in a critical section.
Definition: threadqimpl.h:603
RTEMS_INLINE_ROUTINE void _Priority_Initialize_empty(Priority_Aggregation *aggregation)
Initializes the priority aggregation empty.
Definition: priorityimpl.h:211
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdogticks.h:38
RTEMS_INLINE_ROUTINE size_t _Thread_queue_Context_save_priority_updates(Thread_queue_Context *queue_context)
Returns the priority update count of the thread queue context.
Definition: threadqimpl.h:353
void _Thread_queue_Initialize(Thread_queue_Control *the_thread_queue, const char *name)
Initializes the thread queue control to the given name.
Definition: threadq.c:137
bool _Thread_queue_Extract_locked(Thread_queue_Queue *queue, const Thread_queue_Operations *operations, Thread_Control *the_thread, Thread_queue_Context *queue_context)
Extracts the thread from the thread queue, restores the default wait operations and restores the defa...
Definition: threadqenqueue.c:565
struct Thread_queue_Context::@3985 Priority
Block to manage thread priority changes due to a thread queue operation.
Thread queue context for the thread queue methods.
Definition: threadq.h:198
#define _Thread_queue_Context_set_MP_callout(queue_context, mp_callout)
Sets the MP callout in the thread queue context.
Definition: threadqimpl.h:456
Thread_Control * update[2]
Threads to update the priority via _Thread_Priority_update().
Definition: threadq.h:293
Thread_queue_Enqueue_callout enqueue_callout
The enqueue callout for _Thread_queue_Enqueue().
Definition: threadq.h:221
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_timeout_argument(Thread_queue_Context *queue_context, const void *arg)
Sets the timeout argument in the thread queue context.
Definition: threadqimpl.h:212
Priority Handler API Implementation.
Constants and Structures Related with Thread Dispatch.
Thread_queue_Deadlock_callout deadlock_callout
Invoked in case of a detected deadlock.
Definition: threadq.h:304
RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_empty(const Thread_queue_Queue *queue)
Checks if the thread queue queue is empty.
Definition: threadqimpl.h:1152
Definition: chain.h:86
RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty(Chain_Control *the_chain)
Initializes this chain as empty.
Definition: chainimpl.h:505
RTEMS_INLINE_ROUTINE void _Thread_queue_Release_critical(Thread_queue_Control *the_thread_queue, Thread_queue_Context *queue_context)
Releases the thread queue control in a critical section.
Definition: threadqimpl.h:764
RTEMS_INLINE_ROUTINE void _Thread_queue_Heads_initialize(Thread_queue_Heads *heads)
Initializes the thread queue heads.
Definition: threadqimpl.h:523
#define _ISR_lock_ISR_enable(_context)
Restores the saved interrupt state of the ISR lock context.
Definition: isrlock.h:419
union Thread_queue_Context::@3984 Timeout
Interval to wait.
Definition: threadq.h:552
Thread_Control * _Thread_queue_Flush_status_unavailable(Thread_Control *the_thread, Thread_queue_Queue *queue, Thread_queue_Context *queue_context)
Status unavailable thread queue flush filter function.
Definition: threadqflush.c:50
Thread_queue_First_operation first
Thread queue first operation.
Definition: threadq.h:545
Thread_queue_Priority_queue Priority
This is the set of threads for priority discipline waiting.
Definition: threadq.h:378
void _Thread_queue_Object_initialize(Thread_queue_Control *the_thread_queue)
Initializes a thread queue embedded in an object with identifier.
Definition: threadq.c:148
Constants and Structures Needed to Declare a Thread Queue.
#define _ISR_Get_level()
Return current interrupt level.
Definition: isrlevel.h:128
Definition: threadq.h:402
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_timeout_ticks(Thread_queue_Context *queue_context, Watchdog_Interval ticks)
Sets the timeout ticks in the thread queue context.
Definition: threadqimpl.h:195
void _Thread_queue_Unblock_critical(bool unblock, Thread_queue_Queue *queue, Thread_Control *the_thread, ISR_lock_Context *lock_context)
Unblocks the thread which was on the thread queue before.
Definition: threadqenqueue.c:579
SuperCore SMP Support API.
uint32_t States_Control
Definition: states.h:46
Thread queue operations.
Definition: threadq.h:517
size_t update_count
Count of threads to update the priority via _Thread_Priority_update().
Definition: threadq.h:284
size_t _Thread_queue_Queue_get_name_and_id(const Thread_queue_Queue *queue, char *buffer, size_t buffer_size, Objects_Id *id)
Copies the thread queue name to the specified buffer.
Definition: threadq.c:163
Thread_Control * _Thread_queue_Flush_default_filter(Thread_Control *the_thread, Thread_queue_Queue *queue, Thread_queue_Context *queue_context)
Default thread queue flush filter function.
Definition: threadqflush.c:26
Thread_Control *(* Thread_queue_Flush_filter)(Thread_Control *the_thread, Thread_queue_Queue *queue, Thread_queue_Context *queue_context)
Thread queue flush filter function.
Definition: threadqimpl.h:1223
Thread_Control * _Thread_queue_Do_dequeue(Thread_queue_Control *the_thread_queue, const Thread_queue_Operations *operations)
Dequeues the first thread waiting on the thread queue and returns it.
Definition: threadqenqueue.c:742
Thread_queue_Queue Queue
The actual thread queue.
Definition: threadq.h:583
Thread_queue_Heads * heads
Lock to protect this thread queue.
Definition: threadq.h:426
Thread queue heads.
Definition: threadq.h:360
Chain_Control Free_chain
A chain with free thread queue heads providing the spare thread queue heads for a thread once it is d...
Definition: threadq.h:386
void _Thread_queue_Deadlock_fatal(Thread_Control *the_thread)
Results in an INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK fatal error.
Definition: threadqenqueue.c:375
Priority_Aggregation Queue
The actual thread priority queue.
Definition: threadq.h:338
void _Thread_queue_Deadlock_status(Thread_Control *the_thread)
Sets the thread wait return code to STATUS_DEADLOCK.
Definition: threadqenqueue.c:370
Definition: thread.h:732
Thread queue with a layout compatible to struct _Thread_queue_Queue defined in Newlib <sys/lock....
Definition: threadqimpl.h:54
void _Thread_queue_Enqueue_do_nothing_extra(Thread_queue_Queue *queue, Thread_Control *the_thread, Per_CPU_Control *cpu_self, Thread_queue_Context *queue_context)
Does nothing.
Definition: threadqenqueue.c:360
RTEMS_INLINE_ROUTINE void _Thread_queue_Destroy(Thread_queue_Control *the_thread_queue)
Destroys the thread queue.
Definition: threadqimpl.h:1378
size_t _Thread_queue_Flush_critical(Thread_queue_Queue *queue, const Thread_queue_Operations *operations, Thread_queue_Flush_filter filter, Thread_queue_Context *queue_context)
Unblocks all threads enqueued on the thread queue.
Definition: threadqflush.c:63
Per CPU Core Structure.
Definition: percpu.h:347
const char * name
The thread queue name.
Definition: threadq.h:436
#define _Scheduler_Count
Count of registered schedulers.
Definition: scheduler.h:325
uint32_t ISR_Level
Definition: isrlevel.h:41
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_enqueue_callout(Thread_queue_Context *queue_context, Thread_queue_Enqueue_callout enqueue_callout)
Sets the enqueue callout in the thread queue context.
Definition: threadqimpl.h:229
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_add_priority_update(Thread_queue_Context *queue_context, Thread_Control *the_thread)
Adds a priority update of the thread to the thread queue context.
Definition: threadqimpl.h:383
void(* Thread_queue_Enqueue_callout)(Thread_queue_Queue *queue, Thread_Control *the_thread, struct Per_CPU_Control *cpu_self, Thread_queue_Context *queue_context)
Thread queue enqueue callout.
Definition: threadq.h:72
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:203
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_thread_state(Thread_queue_Context *queue_context, States_Control thread_state)
Sets the thread state for the thread to enqueue in the thread queue context.
Definition: threadqimpl.h:178
RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize(Thread_queue_Queue *queue, const char *name)
Initializes the thread queue queue with the given name.
Definition: threadqimpl.h:547
void _Thread_queue_Extract_with_proxy(Thread_Control *the_thread)
Extracts the_thread from the_thread_queue.
Definition: threadqextractwithproxy.c:30
Thread_Control * _Thread_queue_Flush_status_object_was_deleted(Thread_Control *the_thread, Thread_queue_Queue *queue, Thread_queue_Context *queue_context)
Status object was deleted thread queue flush filter function.
Definition: threadqflush.c:37
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_ISR_level(Thread_queue_Context *queue_context, ISR_Level level)
Sets the thread queue context ISR level.
Definition: threadqimpl.h:411
RTEMS_INLINE_ROUTINE void _Thread_queue_Do_release_critical(Thread_queue_Control *the_thread_queue, ISR_lock_Context *lock_context)
Checks if the thread queue control is the owner of the lock.
Definition: threadqimpl.h:747
void _Thread_queue_Surrender(Thread_queue_Queue *queue, Thread_queue_Heads *heads, Thread_Control *previous_owner, Thread_queue_Context *queue_context, const Thread_queue_Operations *operations)
Surrenders the thread queue previously owned by the thread to the first enqueued thread.
Definition: threadqenqueue.c:660
const Scheduler_Control _Scheduler_Table[]
Registered schedulers.
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_enqueue_do_nothing_extra(Thread_queue_Context *queue_context)
Sets the do nothing enqueue callout in the thread queue context.
Definition: threadqimpl.h:245
void _Thread_queue_Add_timeout_ticks(Thread_queue_Queue *queue, Thread_Control *the_thread, Per_CPU_Control *cpu_self, Thread_queue_Context *queue_context)
Adds timeout ticks of the queue to the thread.
Definition: threadqtimeout.c:17
Chain Handler API.
RTEMS_INLINE_ROUTINE void _Thread_queue_Do_acquire_critical(Thread_queue_Control *the_thread_queue, ISR_lock_Context *lock_context)
Acquires the thread queue control in a critical section.
Definition: threadqimpl.h:665
RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_do_acquire_critical(Thread_queue_Queue *queue, ISR_lock_Context *lock_context)
Acquires the thread queue queue in a critical section.
Definition: threadqimpl.h:567
RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire_critical(Thread_queue_Control *the_thread_queue, Thread_queue_Context *queue_context)
Acquires the thread queue control in a critical section.
Definition: threadqimpl.h:681
void _Thread_queue_Add_timeout_monotonic_timespec(Thread_queue_Queue *queue, Thread_Control *the_thread, Per_CPU_Control *cpu_self, Thread_queue_Context *queue_context)
Adds a monotonic timespec to the thread and sets the watchdog header to monotonic.
Definition: threadqtimeout.c:90
RTEMS_INLINE_ROUTINE void _Chain_Append_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Appends a node (unprotected).
Definition: chainimpl.h:680
States_Control thread_state
The thread state for _Thread_queue_Enqueue().
Definition: threadq.h:208
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_clear_priority_updates(Thread_queue_Context *queue_context)
Clears the priority update count of the thread queue context.
Definition: threadqimpl.h:338
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize(Thread_queue_Context *queue_context)
Initializes a thread queue context.
Definition: threadqimpl.h:152
Chain_Node Free_node
A chain node to add these thread queue heads to the free chain of the thread queue heads dedicated to...
Definition: threadq.h:392
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_enqueue_timeout_ticks(Thread_queue_Context *queue_context, Watchdog_Interval ticks)
Sets the enqueue callout to add a relative monotonic timeout in ticks.
Definition: threadqimpl.h:262
const char _Thread_queue_Object_name[]
The special thread queue name to indicated that the thread queue is embedded in an object with identi...
Definition: threadq.c:135
Thread_Control * _Thread_queue_First(Thread_queue_Control *the_thread_queue, const Thread_queue_Operations *operations)
Returns the first thread on the thread queue if it exists, otherwise NULL.
Definition: threadqfirst.c:23
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_enqueue_timeout_realtime_timespec(Thread_queue_Context *queue_context, const struct timespec *abstime)
Sets the enqueue callout to add an absolute realtime timeout in timespec format.
Definition: threadqimpl.h:301
#define _ISR_lock_ISR_disable(_context)
Disables interrupts and saves the previous interrupt state in the ISR lock context.
Definition: isrlock.h:398
uint32_t Objects_Id
Definition: object.h:80
const void * arg
The timeout argument, e.g. pointer to struct timespec.
Definition: threadq.h:237
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_deadlock_callout(Thread_queue_Context *queue_context, Thread_queue_Deadlock_callout deadlock_callout)
Sets the deadlock callout in the thread queue context.
Definition: threadqimpl.h:324
void _Thread_queue_Add_timeout_realtime_timespec(Thread_queue_Queue *queue, Thread_Control *the_thread, Per_CPU_Control *cpu_self, Thread_queue_Context *queue_context)
Adds a monotonic timespec to the thread and sets the watchdog header to realtime.
Definition: threadqtimeout.c:110
void _Thread_queue_Extract(Thread_Control *the_thread)
Extracts thread from thread queue.
Definition: threadqenqueue.c:624
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_restore_priority_updates(Thread_queue_Context *queue_context, size_t update_count)
Sets the priority update count of the thread queue context.
Definition: threadqimpl.h:367
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:130
RTEMS_INLINE_ROUTINE void _Thread_queue_Release(Thread_queue_Control *the_thread_queue, Thread_queue_Context *queue_context)
Releases the thread queue control and enables interrupts.
Definition: threadqimpl.h:787
void _Thread_queue_Enqueue(Thread_queue_Queue *queue, const Thread_queue_Operations *operations, Thread_Control *the_thread, Thread_queue_Context *queue_context)
Blocks the thread and places it on the thread queue.
Definition: threadqenqueue.c:380
RTEMS_INLINE_ROUTINE void _ISR_lock_Context_set_level(ISR_lock_Context *context, ISR_Level level)
Sets the ISR level in the ISR lock context.
Definition: isrlock.h:159
void _Thread_queue_Extract_critical(Thread_queue_Queue *queue, const Thread_queue_Operations *operations, Thread_Control *the_thread, Thread_queue_Context *queue_context)
Extracts the thread from the thread queue and unblocks it.
Definition: threadqenqueue.c:600
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
Constants and Structures Associated with the Scheduler.
Constants and Structures Related with the Thread Control Block.
RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release(Thread_queue_Queue *queue, ISR_lock_Context *lock_context)
Releases the thread queue queue and enables interrupts.
Definition: threadqimpl.h:625
RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire(Thread_queue_Control *the_thread_queue, Thread_queue_Context *queue_context)
Acquires the thread queue control in a critical section.
Definition: threadqimpl.h:704
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:100
Does nothing.
Definition: threadqimpl.h:1445
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77