RTEMS 6.1-rc6
Loading...
Searching...
No Matches
threadqimpl.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * COPYRIGHT (c) 1989-2014.
14 * On-Line Applications Research Corporation (OAR).
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _RTEMS_SCORE_THREADQIMPL_H
39#define _RTEMS_SCORE_THREADQIMPL_H
40
41#include <rtems/score/threadq.h>
45#include <rtems/score/smp.h>
46#include <rtems/score/status.h>
47#include <rtems/score/thread.h>
49
50#if defined(RTEMS_DEBUG)
51#include <string.h>
52#endif
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
64#define THREAD_QUEUE_LINK_OF_PATH_NODE( node ) \
65 RTEMS_CONTAINER_OF( node, Thread_queue_Link, Path_node );
66
71typedef struct {
72#if !defined(RTEMS_SMP)
73 /*
74 * The struct _Thread_queue_Queue definition is independent of the RTEMS
75 * build configuration. Thus, the storage space for the SMP lock is always
76 * present. In SMP configurations, the SMP lock is contained in the
77 * Thread_queue_Queue.
78 */
79 unsigned int reserved[2];
80#endif
81
84
94 Thread_queue_Queue *queue,
95 Thread_Control *the_thread,
96 Per_CPU_Control *cpu_self,
97 Thread_queue_Context *queue_context
98);
99
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
143 Thread_queue_Queue *queue,
144 Thread_Control *the_thread,
145 Per_CPU_Control *cpu_self,
146 Thread_queue_Context *queue_context
147);
148
156
163
169static inline void _Thread_queue_Context_initialize(
170 Thread_queue_Context *queue_context
171)
172{
173#if defined(RTEMS_DEBUG)
174 memset( queue_context, 0x7f, sizeof( *queue_context ) );
175#if defined(RTEMS_SMP)
176 _Chain_Initialize_node( &queue_context->Lock_context.Wait.Gate.Node );
177#endif
178 queue_context->enqueue_callout = NULL;
179 queue_context->deadlock_callout = NULL;
180#else
181 (void) queue_context;
182#endif
183}
184
194static inline void
195_Thread_queue_Context_set_thread_state(
196 Thread_queue_Context *queue_context,
197 States_Control thread_state
198)
199{
200 queue_context->thread_state = thread_state;
201}
202
211static inline void
212_Thread_queue_Context_set_timeout_ticks(
213 Thread_queue_Context *queue_context,
215)
216{
217 queue_context->Timeout.ticks = ticks;
218}
219
232static inline void
233_Thread_queue_Context_set_timeout_argument(
234 Thread_queue_Context *queue_context,
235 const void *arg,
236 bool absolute
237)
238{
239 queue_context->Timeout.arg = arg;
240 queue_context->timeout_absolute = absolute;
241}
242
251static inline void
252_Thread_queue_Context_set_enqueue_callout(
253 Thread_queue_Context *queue_context,
254 Thread_queue_Enqueue_callout enqueue_callout
255)
256{
257 queue_context->enqueue_callout = enqueue_callout;
258}
259
267static inline void
268_Thread_queue_Context_set_enqueue_do_nothing_extra(
269 Thread_queue_Context *queue_context
270)
271{
273}
274
284static inline void
285_Thread_queue_Context_set_enqueue_timeout_ticks(
286 Thread_queue_Context *queue_context,
288)
289{
290 queue_context->Timeout.ticks = ticks;
292}
293
307static inline void
308_Thread_queue_Context_set_enqueue_timeout_monotonic_timespec(
309 Thread_queue_Context *queue_context,
310 const struct timespec *timeout,
311 bool absolute
312)
313{
314 queue_context->Timeout.arg = timeout;
315 queue_context->timeout_absolute = absolute;
316 queue_context->enqueue_callout =
318}
319
333static inline void
334_Thread_queue_Context_set_enqueue_timeout_realtime_timespec(
335 Thread_queue_Context *queue_context,
336 const struct timespec *timeout,
337 bool absolute
338)
339{
340 queue_context->Timeout.arg = timeout;
341 queue_context->timeout_absolute = absolute;
343}
344
359static inline void _Thread_queue_Context_set_deadlock_callout(
360 Thread_queue_Context *queue_context,
361 Thread_queue_Deadlock_callout deadlock_callout
362)
363{
364 queue_context->deadlock_callout = deadlock_callout;
365}
366
373static inline void _Thread_queue_Context_clear_priority_updates(
374 Thread_queue_Context *queue_context
375)
376{
377 queue_context->Priority.update_count = 0;
378}
379
388static inline size_t _Thread_queue_Context_get_priority_updates(
389 const Thread_queue_Context *queue_context
390)
391{
392 return queue_context->Priority.update_count;
393}
394
402static inline void _Thread_queue_Context_restore_priority_updates(
403 Thread_queue_Context *queue_context,
404 size_t update_count
405)
406{
407 queue_context->Priority.update_count = update_count;
408}
409
418static inline void _Thread_queue_Context_add_priority_update(
419 Thread_queue_Context *queue_context,
420 Thread_Control *the_thread
421)
422{
423 size_t n;
424
425 n = queue_context->Priority.update_count;
426 _Assert( n < RTEMS_ARRAY_SIZE( queue_context->Priority.update ) );
427
428 queue_context->Priority.update_count = n + 1;
429 queue_context->Priority.update[ n ] = the_thread;
430}
431
432#define _Thread_queue_Context_ISR_disable( queue_context, level ) \
433 do { \
434 _ISR_Local_disable( level ); \
435 _ISR_lock_ISR_disable_profile( \
436 &( queue_context )->Lock_context.Lock_context \
437 ) \
438 } while ( 0 )
439
446static inline void _Thread_queue_Context_set_ISR_level(
447 Thread_queue_Context *queue_context,
448 ISR_Level level
449)
450{
451 _ISR_lock_Context_set_level(
452 &queue_context->Lock_context.Lock_context,
453 level
454 );
455}
456
464static inline Per_CPU_Control *_Thread_queue_Dispatch_disable(
465 Thread_queue_Context *queue_context
466)
467{
468 return _Thread_Dispatch_disable_critical(
469 &queue_context->Lock_context.Lock_context
470 );
471}
472
482#if defined(RTEMS_MULTIPROCESSING)
483static inline void _Thread_queue_Context_set_MP_callout(
484 Thread_queue_Context *queue_context,
485 Thread_queue_MP_callout mp_callout
486)
487{
488 queue_context->mp_callout = mp_callout;
489}
490#else
491#define _Thread_queue_Context_set_MP_callout( queue_context, mp_callout ) \
492 do { \
493 (void) queue_context; \
494 } while ( 0 )
495#endif
496
497#if defined(RTEMS_SMP)
503static inline void _Thread_queue_Gate_close(
504 Thread_queue_Gate *gate
505)
506{
507 _Atomic_Store_uint( &gate->go_ahead, 0, ATOMIC_ORDER_RELAXED );
508}
509
516static inline void _Thread_queue_Gate_add(
517 Chain_Control *chain,
518 Thread_queue_Gate *gate
519)
520{
521 _Chain_Append_unprotected( chain, &gate->Node );
522}
523
529static inline void _Thread_queue_Gate_open(
530 Thread_queue_Gate *gate
531)
532{
533 _Atomic_Store_uint( &gate->go_ahead, 1, ATOMIC_ORDER_RELAXED );
534}
535
543static inline void _Thread_queue_Gate_wait(
544 Thread_queue_Gate *gate
545)
546{
547 while ( _Atomic_Load_uint( &gate->go_ahead, ATOMIC_ORDER_RELAXED ) == 0 ) {
548 /* Wait */
549 }
550}
551#endif
552
558static inline void _Thread_queue_Heads_initialize(
559 Thread_queue_Heads *heads
560)
561{
562#if defined(RTEMS_SMP)
563 size_t i;
564
565 for ( i = 0; i < _Scheduler_Count; ++i ) {
566 _Chain_Initialize_node( &heads->Priority[ i ].Node );
567 _Priority_Initialize_empty( &heads->Priority[ i ].Queue );
568 heads->Priority[ i ].Queue.scheduler = &_Scheduler_Table[ i ];
569 }
570#endif
571
572 _Chain_Initialize_empty( &heads->Free_chain );
573 _Chain_Initialize_node( &heads->Free_node );
574}
575
582static inline void _Thread_queue_Queue_initialize(
583 Thread_queue_Queue *queue,
584 const char *name
585)
586{
587#if defined(RTEMS_SMP)
588 _SMP_ticket_lock_Initialize( &queue->Lock );
589#endif
590 queue->heads = NULL;
591 queue->owner = NULL;
592 queue->name = name;
593}
594
602static inline void _Thread_queue_Queue_do_acquire_critical(
603 Thread_queue_Queue *queue,
604#if defined(RTEMS_SMP) && defined(RTEMS_PROFILING)
605 SMP_lock_Stats *lock_stats,
606#endif
607 ISR_lock_Context *lock_context
608)
609{
610#if defined(RTEMS_SMP)
611 _SMP_ticket_lock_Acquire(
612 &queue->Lock,
613 lock_stats,
614 &lock_context->Lock_context.Stats_context
615 );
616#else
617 (void) queue;
618 (void) lock_context;
619#endif
620}
621
622#if defined(RTEMS_SMP) && defined( RTEMS_PROFILING )
623 #define \
624 _Thread_queue_Queue_acquire_critical( queue, lock_stats, lock_context ) \
625 _Thread_queue_Queue_do_acquire_critical( queue, lock_stats, lock_context )
626#else
627 #define \
628 _Thread_queue_Queue_acquire_critical( queue, lock_stats, lock_context ) \
629 _Thread_queue_Queue_do_acquire_critical( queue, lock_context )
630#endif
631
638static inline void _Thread_queue_Queue_release_critical(
639 Thread_queue_Queue *queue,
640 ISR_lock_Context *lock_context
641)
642{
643#if defined(RTEMS_SMP)
644 _SMP_ticket_lock_Release(
645 &queue->Lock,
646 &lock_context->Lock_context.Stats_context
647 );
648#else
649 (void) queue;
650 (void) lock_context;
651#endif
652}
653
660static inline void _Thread_queue_Queue_release(
661 Thread_queue_Queue *queue,
662 ISR_lock_Context *lock_context
663)
664{
665 _Thread_queue_Queue_release_critical( queue, lock_context );
666 _ISR_lock_ISR_enable( lock_context );
667}
668
682 const Thread_queue_Queue *queue,
683 char *buffer,
684 size_t buffer_size,
685 Objects_Id *id
686);
687
694#if defined(RTEMS_SMP)
695void _Thread_queue_Do_acquire_critical(
696 Thread_queue_Control *the_thread_queue,
697 ISR_lock_Context *lock_context
698);
699#else
700static inline void _Thread_queue_Do_acquire_critical(
701 Thread_queue_Control *the_thread_queue,
702 ISR_lock_Context *lock_context
703)
704{
705 (void) the_thread_queue;
706 (void) lock_context;
707}
708#endif
709
716static inline void _Thread_queue_Acquire_critical(
717 Thread_queue_Control *the_thread_queue,
718 Thread_queue_Context *queue_context
719)
720{
721 _Thread_queue_Do_acquire_critical(
722 the_thread_queue,
723 &queue_context->Lock_context.Lock_context
724 );
725}
726
733#if defined(RTEMS_SMP)
734void _Thread_queue_Acquire(
735 Thread_queue_Control *the_thread_queue,
736 Thread_queue_Context *queue_context
737);
738#else
739static inline void _Thread_queue_Acquire(
740 Thread_queue_Control *the_thread_queue,
741 Thread_queue_Context *queue_context
742)
743{
744 (void) the_thread_queue;
746}
747#endif
748
757#if defined(RTEMS_DEBUG)
758static inline bool _Thread_queue_Is_lock_owner(
759 const Thread_queue_Control *the_thread_queue
760)
761{
762#if defined(RTEMS_SMP)
763 return the_thread_queue->owner == _SMP_lock_Who_am_I();
764#else
765 return _ISR_Get_level() != 0;
766#endif
767}
768#endif
769
776#if defined(RTEMS_SMP)
777void _Thread_queue_Do_release_critical(
778 Thread_queue_Control *the_thread_queue,
779 ISR_lock_Context *lock_context
780);
781#else
782static inline void _Thread_queue_Do_release_critical(
783 Thread_queue_Control *the_thread_queue,
784 ISR_lock_Context *lock_context
785)
786{
787 (void) the_thread_queue;
788 (void) lock_context;
789 _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) );
790}
791#endif
792
799static inline void _Thread_queue_Release_critical(
800 Thread_queue_Control *the_thread_queue,
801 Thread_queue_Context *queue_context
802)
803{
804 _Thread_queue_Do_release_critical(
805 the_thread_queue,
806 &queue_context->Lock_context.Lock_context
807 );
808}
809
816#if defined(RTEMS_SMP)
817void _Thread_queue_Release(
818 Thread_queue_Control *the_thread_queue,
819 Thread_queue_Context *queue_context
820);
821#else
822static inline void _Thread_queue_Release(
823 Thread_queue_Control *the_thread_queue,
824 Thread_queue_Context *queue_context
825)
826{
827 (void) the_thread_queue;
828 _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) );
830}
831#endif
832
911 Thread_queue_Queue *queue,
912 const Thread_queue_Operations *operations,
913 Thread_Control *the_thread,
914 Thread_queue_Context *queue_context
915);
916
917#if defined(RTEMS_SMP)
940Status_Control _Thread_queue_Enqueue_sticky(
941 Thread_queue_Queue *queue,
942 const Thread_queue_Operations *operations,
943 Thread_Control *the_thread,
944 Thread_queue_Context *queue_context
945);
946#endif
947
968 Thread_queue_Queue *queue,
969 const Thread_queue_Operations *operations,
970 Thread_Control *the_thread,
971 Thread_queue_Context *queue_context
972);
973
989 Thread_queue_Queue *queue,
990 Thread_Control *the_thread,
991 Thread_queue_Context *queue_context
992);
993
1003void _Thread_queue_Extract( Thread_Control *the_thread );
1004
1022 Thread_queue_Queue *queue,
1023 Thread_queue_Heads *heads,
1024 Thread_Control *previous_owner,
1025 Thread_queue_Context *queue_context,
1026 const Thread_queue_Operations *operations
1027);
1028
1044 Thread_queue_Queue *queue,
1045 Thread_queue_Heads *heads,
1046 Thread_queue_Context *queue_context,
1047 const Thread_queue_Operations *operations
1048);
1049
1065 Thread_queue_Queue *queue,
1066 Thread_Control *executing,
1067 Priority_Node *ceiling_priority,
1068 Thread_queue_Context *queue_context,
1069 const Thread_queue_Operations *operations
1070);
1071
1072#if defined(RTEMS_SMP)
1093void _Thread_queue_Surrender_sticky(
1094 Thread_queue_Queue *queue,
1095 Thread_queue_Heads *heads,
1096 Thread_Control *previous_owner,
1097 Thread_queue_Context *queue_context,
1098 const Thread_queue_Operations *operations
1099);
1100#endif
1101
1110static inline bool _Thread_queue_Is_empty(
1111 const Thread_queue_Queue *queue
1112)
1113{
1114 return queue->heads == NULL;
1115}
1116
1128 Thread_queue_Control *the_thread_queue,
1129 const Thread_queue_Operations *operations
1130);
1131
1153typedef Thread_Control *( *Thread_queue_Flush_filter )(
1154 Thread_Control *the_thread,
1155 Thread_queue_Queue *queue,
1156 Thread_queue_Context *queue_context
1157);
1158
1169 Thread_Control *the_thread,
1170 Thread_queue_Queue *queue,
1171 Thread_queue_Context *queue_context
1172);
1173
1186 Thread_Control *the_thread,
1187 Thread_queue_Queue *queue,
1188 Thread_queue_Context *queue_context
1189);
1190
1203 Thread_Control *the_thread,
1204 Thread_queue_Queue *queue,
1205 Thread_queue_Context *queue_context
1206);
1207
1231 Thread_queue_Queue *queue,
1232 const Thread_queue_Operations *operations,
1234 Thread_queue_Context *queue_context
1235);
1236
1244 Thread_queue_Control *the_thread_queue,
1245 const char *name
1246);
1247
1248#if defined(RTEMS_SMP) && defined(RTEMS_DEBUG) && defined(RTEMS_PROFILING)
1249 #define THREAD_QUEUE_INITIALIZER( _name ) \
1250 { \
1251 .Lock_stats = SMP_LOCK_STATS_INITIALIZER( _name ), \
1252 .owner = SMP_LOCK_NO_OWNER, \
1253 .Queue = { \
1254 .Lock = SMP_TICKET_LOCK_INITIALIZER, \
1255 .heads = NULL, \
1256 .owner = NULL, \
1257 .name = _name \
1258 } \
1259 }
1260#elif defined(RTEMS_SMP) && defined(RTEMS_DEBUG)
1261 #define THREAD_QUEUE_INITIALIZER( _name ) \
1262 { \
1263 .owner = SMP_LOCK_NO_OWNER, \
1264 .Queue = { \
1265 .Lock = SMP_TICKET_LOCK_INITIALIZER, \
1266 .heads = NULL, \
1267 .owner = NULL, \
1268 .name = _name \
1269 } \
1270 }
1271#elif defined(RTEMS_SMP) && defined(RTEMS_PROFILING)
1272 #define THREAD_QUEUE_INITIALIZER( _name ) \
1273 { \
1274 .Lock_stats = SMP_LOCK_STATS_INITIALIZER( _name ), \
1275 .Queue = { \
1276 .Lock = SMP_TICKET_LOCK_INITIALIZER, \
1277 .heads = NULL, \
1278 .owner = NULL, \
1279 .name = _name \
1280 } \
1281 }
1282#elif defined(RTEMS_SMP)
1283 #define THREAD_QUEUE_INITIALIZER( _name ) \
1284 { \
1285 .Queue = { \
1286 .Lock = SMP_TICKET_LOCK_INITIALIZER, \
1287 .heads = NULL, \
1288 .owner = NULL, \
1289 .name = _name \
1290 } \
1291 }
1292#else
1293 #define THREAD_QUEUE_INITIALIZER( _name ) \
1294 { \
1295 .Queue = { \
1296 .heads = NULL, \
1297 .owner = NULL, \
1298 .name = _name \
1299 } \
1300 }
1301#endif
1302
1308static inline void _Thread_queue_Destroy(
1309 Thread_queue_Control *the_thread_queue
1310)
1311{
1312#if defined(RTEMS_SMP)
1313 _SMP_ticket_lock_Destroy( &the_thread_queue->Queue.Lock );
1314 _SMP_lock_Stats_destroy( &the_thread_queue->Lock_stats );
1315#endif
1316}
1317
1318#if defined(RTEMS_MULTIPROCESSING)
1325void _Thread_queue_MP_callout_do_nothing(
1326 Thread_Control *the_proxy,
1327 Objects_Id mp_id
1328);
1329
1330bool _Thread_queue_MP_set_callout(
1331 Thread_Control *the_thread,
1332 const Thread_queue_Context *queue_context
1333);
1334
1341void _Thread_queue_Unblock_proxy(
1342 Thread_queue_Queue *queue,
1343 Thread_Control *the_thread
1344);
1345#endif
1346
1350typedef enum {
1355
1361
1362#if defined(RTEMS_SMP)
1383Thread_queue_Deadlock_status _Thread_queue_Path_acquire(
1384 Thread_queue_Queue *queue,
1385 Thread_Control *the_thread,
1386 Thread_queue_Context *queue_context
1387);
1388
1397void _Thread_queue_Path_release(
1398 Thread_queue_Context *queue_context
1399);
1400#endif
1401
1408typedef struct {
1409 Objects_Control Object;
1410 Thread_queue_Control Wait_queue;
1412
1413#define THREAD_QUEUE_OBJECT_ASSERT( object_type, wait_queue_member, msg ) \
1414 RTEMS_STATIC_ASSERT( \
1415 offsetof( object_type, wait_queue_member ) \
1416 == offsetof( Thread_queue_Object, Wait_queue ) \
1417 && RTEMS_HAVE_MEMBER_SAME_TYPE( \
1418 object_type, \
1419 wait_queue_member, \
1420 Thread_queue_Object, \
1421 Wait_queue \
1422 ), \
1423 msg \
1424 )
1425
1426#define THREAD_QUEUE_QUEUE_TO_OBJECT( queue ) \
1427 RTEMS_CONTAINER_OF( \
1428 queue, \
1429 Thread_queue_Object, \
1430 Wait_queue.Queue \
1431 )
1432
1442
1448
1454
1461
1468extern const char _Thread_queue_Object_name[];
1469
1479 Thread_queue_Control *the_thread_queue
1480);
1481
1484#ifdef __cplusplus
1485}
1486#endif
1487
1488#endif
1489/* end of include file */
This header file provides interfaces of the Chain Handler which are only used by the implementation.
This header file provides interfaces of the SMP Support which are used by the implementation and the ...
#define RTEMS_ARRAY_SIZE(_array)
Gets the element count of the array.
Definition: basedefs.h:244
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG and static analysis runs.
Definition: assert.h:96
#define _ISR_lock_ISR_enable(_context)
Restores the saved interrupt state of the ISR lock context.
Definition: isrlock.h:385
#define _ISR_lock_ISR_disable(_context)
Disables interrupts and saves the previous interrupt state in the ISR lock context.
Definition: isrlock.h:364
#define _ISR_Get_level()
Return current interrupt level.
Definition: isrlevel.h:147
uint32_t ISR_Level
Definition: isrlevel.h:60
uint32_t Objects_Id
Definition: object.h:101
#define _Scheduler_Count
This constant contains the count of configured schedulers.
Definition: scheduler.h:395
const Scheduler_Control _Scheduler_Table[]
This table contains the configured schedulers.
uint32_t States_Control
Definition: states.h:65
Status_Control
Status codes.
Definition: status.h:111
const Thread_queue_Operations _Thread_queue_Operations_priority
The FIFO thread queue operations are used when a thread is enqueued on a thread queue and provide pri...
Definition: threadqops.c:1517
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:147
#define _Thread_queue_Context_set_MP_callout(queue_context, mp_callout)
Sets the MP callout in the thread queue context.
Definition: threadqimpl.h:491
Thread_queue_Deadlock_status
This is a status code to indicate if a deadlock was detected or not.
Definition: threadqimpl.h:1350
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:1153
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:691
const Thread_queue_Operations _Thread_queue_Operations_FIFO
The FIFO thread queue operations are used when a thread is enqueued on a thread queue and provide FIF...
Definition: threadqops.c:1509
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:407
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:127
void _Thread_queue_Resume(Thread_queue_Queue *queue, Thread_Control *the_thread, Thread_queue_Context *queue_context)
Resumes the extracted or surrendered thread.
Definition: threadqenqueue.c:663
void _Thread_queue_Deadlock_fatal(Thread_Control *the_thread)
Results in an INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK fatal error.
Definition: threadqenqueue.c:401
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:386
const Thread_queue_Operations _Thread_queue_Operations_priority_inherit
The FIFO thread queue operations are used when a thread is enqueued on a thread queue and provide pri...
Definition: threadqops.c:1525
const Thread_queue_Operations _Thread_queue_Operations_default
The default thread queue operations are used when a thread is not enqueued on a thread queue.
Definition: threadqops.c:1500
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:90
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:649
Status_Control _Thread_queue_Surrender_priority_ceiling(Thread_queue_Queue *queue, Thread_Control *executing, Priority_Node *ceiling_priority, 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:760
void(* Thread_queue_Deadlock_callout)(Thread_Control *the_thread)
Thread queue deadlock callout.
Definition: threadq.h:104
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:157
void _Thread_queue_Surrender_no_priority(Thread_queue_Queue *queue, Thread_queue_Heads *heads, 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:739
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:60
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: threadqgetnameandid.c:46
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:86
void _Thread_queue_Deadlock_status(Thread_Control *the_thread)
Sets the thread wait return code to STATUS_DEADLOCK.
Definition: threadqenqueue.c:396
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:44
void _Thread_queue_Extract(Thread_Control *the_thread)
Extracts thread from thread queue.
Definition: threadqextract.c:47
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:49
void _Thread_queue_Object_initialize(Thread_queue_Control *the_thread_queue)
Initializes a thread queue embedded in an object with identifier.
Definition: threadq.c:170
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:47
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:159
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:73
@ THREAD_QUEUE_DEADLOCK_DETECTED
The operation detected a deadlock.
Definition: threadqimpl.h:1359
@ THREAD_QUEUE_NO_DEADLOCK
The operation did not detect a deadlock.
Definition: threadqimpl.h:1354
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdogticks.h:59
This header file provides interfaces of the Priority Handler which are only used by the implementatio...
This header file provides interfaces of the Scheduler Handler which are used by the implementation an...
This header file provides the interfaces of the Operation Status Support.
This header file provides interfaces of the Thread Handler which are used by the implementation and t...
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:94
Definition: objectdata.h:61
Per CPU Core Structure.
Definition: percpu.h:384
The priority node to build up a priority aggregation.
Definition: priority.h:112
Thread queue context for the thread queue methods.
Definition: threadq.h:216
Thread_queue_Enqueue_callout enqueue_callout
The enqueue callout for _Thread_queue_Enqueue().
Definition: threadq.h:240
union Thread_queue_Context::@4410 Timeout
Interval to wait.
struct Thread_queue_Context::@4411 Priority
Block to manage thread priority changes due to a thread queue operation.
Thread_queue_Deadlock_callout deadlock_callout
Invoked in case of a detected deadlock.
Definition: threadq.h:329
const void * arg
The timeout argument, e.g. pointer to struct timespec.
Definition: threadq.h:256
size_t update_count
Count of threads to update the priority via _Thread_Priority_update().
Definition: threadq.h:309
bool timeout_absolute
If this member is true, the timeout shall be absolute, otherwise it shall be relative to the current ...
Definition: threadq.h:263
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:221
Watchdog_Interval ticks
The timeout in ticks.
Definition: threadq.h:251
States_Control thread_state
The thread state for _Thread_queue_Enqueue().
Definition: threadq.h:226
Thread_Control * update[2]
Threads to update the priority via _Thread_Priority_update().
Definition: threadq.h:318
Definition: threadq.h:609
Thread_queue_Queue Queue
The actual thread queue.
Definition: threadq.h:640
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:148
Helper structure to ensure that all objects containing a thread queue have the right layout.
Definition: threadqimpl.h:1408
The thread queue operations are used to manage the threads of a thread queue.
Definition: threadq.h:554
Priority_Aggregation Queue
The actual thread priority queue.
Definition: threadq.h:363
Definition: threadq.h:427
const char * name
The thread queue name.
Definition: threadq.h:461
Thread_queue_Heads * heads
The thread queue heads.
Definition: threadq.h:451
Thread_Control * owner
The thread queue owner.
Definition: threadq.h:456
Thread queue with a layout compatible to struct _Thread_queue_Queue defined in Newlib <sys/lock....
Definition: threadqimpl.h:71
Definition: thread.h:837
Thread queue heads.
Definition: threadq.h:385
Thread_queue_Priority_queue Priority
This is the set of threads for priority discipline waiting.
Definition: threadq.h:403
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:417
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:411
This header file provides the interfaces of the Thread Handler related to thread dispatching.
This header file provides interfaces of the Thread Queue Handler which are used by the implementation...
This union represents a chain control block.
Definition: chain.h:96