RTEMS: cpukit/include/rtems/score/threadqimpl.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
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>
26#include <rtems/score/priorityimpl.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>
31#include <rtems/score/threaddispatch.h>
32
33#if defined(RTEMS_DEBUG)
34#include <string.h>
35#endif
36
37#ifdef __cplusplus
38extern "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;
66} Thread_queue_Syslock_queue;
67
76void _Thread_queue_Enqueue_do_nothing_extra(
77 Thread_queue_Queue *queue,
78 Thread_Control *the_thread,
79 Per_CPU_Control *cpu_self,
80 Thread_queue_Context *queue_context
81);
82
91void _Thread_queue_Add_timeout_ticks(
92 Thread_queue_Queue *queue,
93 Thread_Control *the_thread,
94 Per_CPU_Control *cpu_self,
95 Thread_queue_Context *queue_context
96);
97
108void _Thread_queue_Add_timeout_monotonic_timespec(
109 Thread_queue_Queue *queue,
110 Thread_Control *the_thread,
111 Per_CPU_Control *cpu_self,
112 Thread_queue_Context *queue_context
113);
114
125void _Thread_queue_Add_timeout_realtime_timespec(
126 Thread_queue_Queue *queue,
127 Thread_Control *the_thread,
128 Per_CPU_Control *cpu_self,
129 Thread_queue_Context *queue_context
130);
131
138void _Thread_queue_Deadlock_status( Thread_Control *the_thread );
139
145void _Thread_queue_Deadlock_fatal( Thread_Control *the_thread );
146
152 RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize(
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
177 RTEMS_INLINE_ROUTINE void
178_Thread_queue_Context_set_thread_state(
179 Thread_queue_Context *queue_context,
180 States_Control thread_state
181)
182{
183 queue_context->thread_state = thread_state;
184}
185
194 RTEMS_INLINE_ROUTINE void
195_Thread_queue_Context_set_timeout_ticks(
196 Thread_queue_Context *queue_context,
197 Watchdog_Interval ticks
198)
199{
200 queue_context->Timeout.ticks = ticks;
201}
202
211 RTEMS_INLINE_ROUTINE void
212_Thread_queue_Context_set_timeout_argument(
213 Thread_queue_Context *queue_context,
214 const void *arg
215)
216{
217 queue_context->Timeout.arg = arg;
218}
219
228 RTEMS_INLINE_ROUTINE void
229_Thread_queue_Context_set_enqueue_callout(
230 Thread_queue_Context *queue_context,
231 Thread_queue_Enqueue_callout enqueue_callout
232)
233{
234 queue_context->enqueue_callout = enqueue_callout;
235}
236
244 RTEMS_INLINE_ROUTINE void
245_Thread_queue_Context_set_enqueue_do_nothing_extra(
246 Thread_queue_Context *queue_context
247)
248{
249 queue_context->enqueue_callout = _Thread_queue_Enqueue_do_nothing_extra;
250}
251
261 RTEMS_INLINE_ROUTINE void
262_Thread_queue_Context_set_enqueue_timeout_ticks(
263 Thread_queue_Context *queue_context,
264 Watchdog_Interval ticks
265)
266{
267 queue_context->Timeout.ticks = ticks;
268 queue_context->enqueue_callout = _Thread_queue_Add_timeout_ticks;
269}
270
280 RTEMS_INLINE_ROUTINE void
281_Thread_queue_Context_set_enqueue_timeout_monotonic_timespec(
282 Thread_queue_Context *queue_context,
283 const struct timespec *abstime
284)
285{
286 queue_context->Timeout.arg = abstime;
287 queue_context->enqueue_callout =
288 _Thread_queue_Add_timeout_monotonic_timespec;
289}
290
300 RTEMS_INLINE_ROUTINE void
301_Thread_queue_Context_set_enqueue_timeout_realtime_timespec(
302 Thread_queue_Context *queue_context,
303 const struct timespec *abstime
304)
305{
306 queue_context->Timeout.arg = abstime;
307 queue_context->enqueue_callout = _Thread_queue_Add_timeout_realtime_timespec;
308}
309
324 RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_deadlock_callout(
325 Thread_queue_Context *queue_context,
326 Thread_queue_Deadlock_callout deadlock_callout
327)
328{
329 queue_context->deadlock_callout = deadlock_callout;
330}
331
338 RTEMS_INLINE_ROUTINE void _Thread_queue_Context_clear_priority_updates(
339 Thread_queue_Context *queue_context
340)
341{
342 queue_context->Priority.update_count = 0;
343}
344
353 RTEMS_INLINE_ROUTINE size_t _Thread_queue_Context_save_priority_updates(
354 Thread_queue_Context *queue_context
355)
356{
357 return queue_context->Priority.update_count;
358}
359
367 RTEMS_INLINE_ROUTINE void _Thread_queue_Context_restore_priority_updates(
368 Thread_queue_Context *queue_context,
369 size_t update_count
370)
371{
372 queue_context->Priority.update_count = update_count;
373}
374
383 RTEMS_INLINE_ROUTINE void _Thread_queue_Context_add_priority_update(
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
411 RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_ISR_level(
412 Thread_queue_Context *queue_context,
413 ISR_Level level
414)
415{
416 _ISR_lock_Context_set_level(
417 &queue_context->Lock_context.Lock_context,
418 level
419 );
420}
421
429 RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_queue_Dispatch_disable(
430 Thread_queue_Context *queue_context
431)
432{
433 return _Thread_Dispatch_disable_critical(
434 &queue_context->Lock_context.Lock_context
435 );
436}
437
447#if defined(RTEMS_MULTIPROCESSING)
448 RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_MP_callout(
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)
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
523 RTEMS_INLINE_ROUTINE void _Thread_queue_Heads_initialize(
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
537 _Chain_Initialize_empty( &heads->Free_chain );
538 _Chain_Initialize_node( &heads->Free_node );
539}
540
547 RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize(
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
567 RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_do_acquire_critical(
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
603 RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release_critical(
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
625 RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release(
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
646size_t _Thread_queue_Queue_get_name_and_id(
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)
660void _Thread_queue_Do_acquire_critical(
661 Thread_queue_Control *the_thread_queue,
662 ISR_lock_Context *lock_context
663);
664#else
665 RTEMS_INLINE_ROUTINE void _Thread_queue_Do_acquire_critical(
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
681 RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire_critical(
682 Thread_queue_Control *the_thread_queue,
683 Thread_queue_Context *queue_context
684)
685{
686 _Thread_queue_Do_acquire_critical(
687 the_thread_queue,
688 &queue_context->Lock_context.Lock_context
689 );
690}
691
698#if defined(RTEMS_SMP)
699void _Thread_queue_Acquire(
700 Thread_queue_Control *the_thread_queue,
701 Thread_queue_Context *queue_context
702);
703#else
704 RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire(
705 Thread_queue_Control *the_thread_queue,
706 Thread_queue_Context *queue_context
707)
708{
709 (void) the_thread_queue;
710 _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
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)
742void _Thread_queue_Do_release_critical(
743 Thread_queue_Control *the_thread_queue,
744 ISR_lock_Context *lock_context
745);
746#else
747 RTEMS_INLINE_ROUTINE void _Thread_queue_Do_release_critical(
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
764 RTEMS_INLINE_ROUTINE void _Thread_queue_Release_critical(
765 Thread_queue_Control *the_thread_queue,
766 Thread_queue_Context *queue_context
767)
768{
769 _Thread_queue_Do_release_critical(
770 the_thread_queue,
771 &queue_context->Lock_context.Lock_context
772 );
773}
774
781#if defined(RTEMS_SMP)
782void _Thread_queue_Release(
783 Thread_queue_Control *the_thread_queue,
784 Thread_queue_Context *queue_context
785);
786#else
787 RTEMS_INLINE_ROUTINE void _Thread_queue_Release(
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 ) );
794 _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context );
795}
796#endif
797
806 Thread_Control *_Thread_queue_Do_dequeue(
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
926void _Thread_queue_Enqueue(
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)
956Status_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
984bool _Thread_queue_Extract_locked(
985 Thread_queue_Queue *queue,
986 const Thread_queue_Operations *operations,
987 Thread_Control *the_thread,
988 Thread_queue_Context *queue_context
989);
990
1005void _Thread_queue_Unblock_critical(
1006 bool unblock,
1007 Thread_queue_Queue *queue,
1008 Thread_Control *the_thread,
1009 ISR_lock_Context *lock_context
1010);
1011
1058void _Thread_queue_Extract_critical(
1059 Thread_queue_Queue *queue,
1060 const Thread_queue_Operations *operations,
1061 Thread_Control *the_thread,
1062 Thread_queue_Context *queue_context
1063);
1064
1074void _Thread_queue_Extract( Thread_Control *the_thread );
1075
1086void _Thread_queue_Extract_with_proxy(
1087 Thread_Control *the_thread
1088);
1089
1106void _Thread_queue_Surrender(
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)
1135void _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
1152 RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_empty(
1153 const Thread_queue_Queue *queue
1154)
1155{
1156 return queue->heads == NULL;
1157}
1158
1173 RTEMS_INLINE_ROUTINE Thread_Control *_Thread_queue_First_locked(
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
1197 Thread_Control *_Thread_queue_First(
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
1238 Thread_Control *_Thread_queue_Flush_default_filter(
1239 Thread_Control *the_thread,
1240 Thread_queue_Queue *queue,
1241 Thread_queue_Context *queue_context
1242);
1243
1255 Thread_Control *_Thread_queue_Flush_status_unavailable(
1256 Thread_Control *the_thread,
1257 Thread_queue_Queue *queue,
1258 Thread_queue_Context *queue_context
1259);
1260
1272 Thread_Control *_Thread_queue_Flush_status_object_was_deleted(
1273 Thread_Control *the_thread,
1274 Thread_queue_Queue *queue,
1275 Thread_queue_Context *queue_context
1276);
1277
1300size_t _Thread_queue_Flush_critical(
1301 Thread_queue_Queue *queue,
1302 const Thread_queue_Operations *operations,
1303 Thread_queue_Flush_filter filter,
1304 Thread_queue_Context *queue_context
1305);
1306
1313void _Thread_queue_Initialize(
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
1378 RTEMS_INLINE_ROUTINE void _Thread_queue_Destroy(
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)
1395void _Thread_queue_MP_callout_do_nothing(
1396 Thread_Control *the_proxy,
1397 Objects_Id mp_id
1398);
1399
1406void _Thread_queue_Unblock_proxy(
1407 Thread_queue_Queue *queue,
1408 Thread_Control *the_thread
1409);
1410#endif
1411
1422#if defined(RTEMS_SMP)
1423bool _Thread_queue_Path_acquire_critical(
1424 Thread_queue_Queue *queue,
1425 Thread_Control *the_thread,
1426 Thread_queue_Context *queue_context
1427);
1428
1434void _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;
1448} Thread_queue_Object;
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
1470extern const Thread_queue_Operations _Thread_queue_Operations_default;
1471
1472extern const Thread_queue_Operations _Thread_queue_Operations_FIFO;
1473
1474extern const Thread_queue_Operations _Thread_queue_Operations_priority;
1475
1476extern const Thread_queue_Operations _Thread_queue_Operations_priority_inherit;
1477
1484extern const char _Thread_queue_Object_name[];
1485
1494void _Thread_queue_Object_initialize(
1495 Thread_queue_Control *the_thread_queue
1496);
1497
1500#ifdef __cplusplus
1501}
1502#endif
1503
1504#endif
1505/* end of include file */
NULL
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
chainimpl.h
Chain Handler API.
_Assert
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:100
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
_Chain_Initialize_empty
RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty(Chain_Control *the_chain)
Initializes this chain as empty.
Definition: chainimpl.h:505
_Chain_Append_unprotected
RTEMS_INLINE_ROUTINE void _Chain_Append_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Appends a node (unprotected).
Definition: chainimpl.h:680
_Chain_Initialize_node
RTEMS_INLINE_ROUTINE void _Chain_Initialize_node(Chain_Node *the_node)
Initializes a chain node.
Definition: chainimpl.h:122
_ISR_lock_ISR_enable
#define _ISR_lock_ISR_enable(_context)
Restores the saved interrupt state of the ISR lock context.
Definition: isrlock.h:419
_ISR_lock_ISR_disable
#define _ISR_lock_ISR_disable(_context)
Disables interrupts and saves the previous interrupt state in the ISR lock context.
Definition: isrlock.h:398
_ISR_lock_Context_set_level
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
_ISR_Get_level
#define _ISR_Get_level()
Return current interrupt level.
Definition: isrlevel.h:128
ISR_Level
uint32_t ISR_Level
Definition: isrlevel.h:41
Objects_Id
uint32_t Objects_Id
Definition: object.h:80
_Priority_Initialize_empty
RTEMS_INLINE_ROUTINE void _Priority_Initialize_empty(Priority_Aggregation *aggregation)
Initializes the priority aggregation empty.
Definition: priorityimpl.h:211
_Scheduler_Count
#define _Scheduler_Count
Count of registered schedulers.
Definition: scheduler.h:325
_Scheduler_Table
const Scheduler_Control _Scheduler_Table[]
Registered schedulers.
States_Control
uint32_t States_Control
Definition: states.h:46
_Thread_queue_Context_set_ISR_level
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
_Thread_queue_First_locked
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
_Thread_queue_Release
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
_Thread_queue_Context_restore_priority_updates
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
_Thread_queue_Add_timeout_realtime_timespec
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
_Thread_queue_Context_set_MP_callout
#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_queue_Flush_filter
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_queue_Acquire_critical
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
_Thread_queue_Surrender
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
_Thread_queue_Context_set_enqueue_timeout_monotonic_timespec
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
_Thread_queue_Is_empty
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
_Thread_queue_Context_set_timeout_ticks
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
_Thread_queue_Acquire
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
_Thread_queue_Enqueue
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
_Thread_queue_Add_timeout_monotonic_timespec
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
_Thread_queue_Queue_release
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
_Thread_queue_Context_set_enqueue_timeout_ticks
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
_Thread_queue_Context_add_priority_update
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
_Thread_queue_Release_critical
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
_Thread_queue_Deadlock_fatal
void _Thread_queue_Deadlock_fatal(Thread_Control *the_thread)
Results in an INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK fatal error.
Definition: threadqenqueue.c:375
_Thread_queue_Enqueue_do_nothing_extra
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
_Thread_queue_Dispatch_disable
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
Thread_queue_Enqueue_callout
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_Extract_locked
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
_Thread_queue_Do_release_critical
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
Thread_queue_Deadlock_callout
void(* Thread_queue_Deadlock_callout)(Thread_Control *the_thread)
Thread queue deadlock callout.
Definition: threadq.h:86
_Thread_queue_Extract_with_proxy
void _Thread_queue_Extract_with_proxy(Thread_Control *the_thread)
Extracts the_thread from the_thread_queue.
Definition: threadqextractwithproxy.c:30
_Thread_queue_Queue_initialize
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
_Thread_queue_Object_name
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_queue_Destroy
RTEMS_INLINE_ROUTINE void _Thread_queue_Destroy(Thread_queue_Control *the_thread_queue)
Destroys the thread queue.
Definition: threadqimpl.h:1378
_Thread_queue_Context_set_enqueue_do_nothing_extra
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
_Thread_queue_Context_set_timeout_argument
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
_Thread_queue_Context_set_deadlock_callout
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
_Thread_queue_Context_set_enqueue_timeout_realtime_timespec
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
_Thread_queue_Context_set_thread_state
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
_Thread_queue_Flush_status_object_was_deleted
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
_Thread_queue_Context_clear_priority_updates
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
_Thread_queue_Queue_get_name_and_id
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_queue_Flush_critical
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
_Thread_queue_Deadlock_status
void _Thread_queue_Deadlock_status(Thread_Control *the_thread)
Sets the thread wait return code to STATUS_DEADLOCK.
Definition: threadqenqueue.c:370
_Thread_queue_Queue_do_acquire_critical
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
_Thread_queue_Do_dequeue
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_First
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
_Thread_queue_Extract
void _Thread_queue_Extract(Thread_Control *the_thread)
Extracts thread from thread queue.
Definition: threadqenqueue.c:624
_Thread_queue_Flush_default_filter
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_queue_Object_initialize
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
_Thread_queue_Context_initialize
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize(Thread_queue_Context *queue_context)
Initializes a thread queue context.
Definition: threadqimpl.h:152
_Thread_queue_Context_set_enqueue_callout
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
_Thread_queue_Unblock_critical
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
_Thread_queue_Add_timeout_ticks
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
_Thread_queue_Initialize
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
_Thread_queue_Context_save_priority_updates
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
_Thread_queue_Heads_initialize
RTEMS_INLINE_ROUTINE void _Thread_queue_Heads_initialize(Thread_queue_Heads *heads)
Initializes the thread queue heads.
Definition: threadqimpl.h:523
_Thread_queue_Do_acquire_critical
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
_Thread_queue_Queue_release_critical
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
_Thread_queue_Extract_critical
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
_Thread_queue_Flush_status_unavailable
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_Dispatch_disable_critical
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
Watchdog_Interval
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdogticks.h:38
priorityimpl.h
Priority Handler API Implementation.
scheduler.h
Constants and Structures Associated with the Scheduler.
thread.h
Constants and Structures Related with the Thread Control Block.
smp.h
SuperCore SMP Support API.
ISR_lock_Context
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
Objects_Control
Definition: objectdata.h:39
Per_CPU_Control
Per CPU Core Structure.
Definition: percpu.h:347
Thread_queue_Context
Thread queue context for the thread queue methods.
Definition: threadq.h:198
Thread_queue_Context::enqueue_callout
Thread_queue_Enqueue_callout enqueue_callout
The enqueue callout for _Thread_queue_Enqueue().
Definition: threadq.h:221
Thread_queue_Context::Priority
struct Thread_queue_Context::@3986 Priority
Block to manage thread priority changes due to a thread queue operation.
Thread_queue_Context::deadlock_callout
Thread_queue_Deadlock_callout deadlock_callout
Invoked in case of a detected deadlock.
Definition: threadq.h:304
Thread_queue_Context::arg
const void * arg
The timeout argument, e.g. pointer to struct timespec.
Definition: threadq.h:237
Thread_queue_Context::update_count
size_t update_count
Count of threads to update the priority via _Thread_Priority_update().
Definition: threadq.h:284
Thread_queue_Context::Lock_context
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:203
Thread_queue_Context::ticks
Watchdog_Interval ticks
The timeout in ticks.
Definition: threadq.h:232
Thread_queue_Context::thread_state
States_Control thread_state
The thread state for _Thread_queue_Enqueue().
Definition: threadq.h:208
Thread_queue_Context::update
Thread_Control * update[2]
Threads to update the priority via _Thread_Priority_update().
Definition: threadq.h:293
Thread_queue_Context::Timeout
union Thread_queue_Context::@3985 Timeout
Interval to wait.
Thread_queue_Control
Definition: threadq.h:553
Thread_queue_Control::Queue
Thread_queue_Queue Queue
The actual thread queue.
Definition: threadq.h:584
Thread_queue_Lock_context::Lock_context
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:130
Thread_queue_Object
Does nothing.
Definition: threadqimpl.h:1445
Thread_queue_Operations
Thread queue operations.
Definition: threadq.h:518
Thread_queue_Operations::first
Thread_queue_First_operation first
Thread queue first operation.
Definition: threadq.h:546
Thread_queue_Priority_queue::Queue
Priority_Aggregation Queue
The actual thread priority queue.
Definition: threadq.h:338
Thread_queue_Queue
Definition: threadq.h:402
Thread_queue_Queue::name
const char * name
The thread queue name.
Definition: threadq.h:436
Thread_queue_Queue::heads
Thread_queue_Heads * heads
Lock to protect this thread queue.
Definition: threadq.h:426
Thread_queue_Queue::owner
Thread_Control * owner
The thread queue owner.
Definition: threadq.h:431
Thread_queue_Syslock_queue
Thread queue with a layout compatible to struct _Thread_queue_Queue defined in Newlib <sys/lock....
Definition: threadqimpl.h:54
_Thread_Control
Definition: thread.h:732
_Thread_queue_Heads
Thread queue heads.
Definition: threadq.h:360
_Thread_queue_Heads::Priority
Thread_queue_Priority_queue Priority
This is the set of threads for priority discipline waiting.
Definition: threadq.h:378
_Thread_queue_Heads::Free_node
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
_Thread_queue_Heads::Free_chain
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
threaddispatch.h
Constants and Structures Related with Thread Dispatch.
threadq.h
Constants and Structures Needed to Declare a Thread Queue.
Chain_Control
Definition: chain.h:86