RTEMS  5.0.0
threadq.h
Go to the documentation of this file.
1 
10 /*
11  * COPYRIGHT (c) 1989-2014.
12  * On-Line Applications Research Corporation (OAR).
13  *
14  * The license and distribution terms for this file may be
15  * found in the file LICENSE in this distribution or at
16  * http://www.rtems.org/license/LICENSE.
17  */
18 
19 #ifndef _RTEMS_SCORE_THREADQ_H
20 #define _RTEMS_SCORE_THREADQ_H
21 
22 #include <rtems/score/chain.h>
23 #include <rtems/score/isrlock.h>
24 #include <rtems/score/object.h>
25 #include <rtems/score/priority.h>
26 #include <rtems/score/rbtree.h>
27 #include <rtems/score/states.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 struct Per_CPU_Control;
35 
36 struct Scheduler_Node;
37 
49 typedef struct _Thread_Control Thread_Control;
50 
52 
54 
56 
67 typedef void ( *Thread_queue_Enqueue_callout )(
68  Thread_queue_Queue *queue,
69  Thread_Control *the_thread,
70  struct Per_CPU_Control *cpu_self,
71  Thread_queue_Context *queue_context
72 );
73 
82  Thread_Control *the_thread
83 );
84 
85 #if defined(RTEMS_MULTIPROCESSING)
86 
96 typedef void ( *Thread_queue_MP_callout )(
97  Thread_Control *the_proxy,
98  Objects_Id mp_id
99 );
100 #endif
101 
102 #if defined(RTEMS_SMP)
103 
113 typedef struct {
114  Chain_Node Node;
115 
116  Atomic_Uint go_ahead;
117 } Thread_queue_Gate;
118 #endif
119 
120 typedef struct {
126 
127 #if defined(RTEMS_SMP)
128 
131  struct {
137  Thread_queue_Gate Gate;
138 
142  Thread_queue_Queue *queue;
143  } Wait;
144 #endif
146 
147 #if defined(RTEMS_SMP)
148 
152 typedef struct {
157  RBTree_Node Registry_node;
158 
162  Thread_queue_Queue *source;
163 
168  Thread_queue_Queue *target;
169 
173  Chain_Node Path_node;
174 
178  Thread_Control *owner;
179 
184  Thread_queue_Lock_context Lock_context;
185 } Thread_queue_Link;
186 #endif
187 
199 
204 
217 
223  union {
228 
232  const void *arg;
233  } Timeout;
234 
235 #if defined(RTEMS_SMP)
236 
246  struct {
250  Chain_Control Links;
251 
255  Thread_queue_Link Start;
256 
261  Thread_queue_Link Deadlock;
262  } Path;
263 #endif
264 
269  struct {
274 
279  size_t update_count;
280 
288  Thread_Control *update[ 2 ];
289  } Priority;
290 
300 
301 #if defined(RTEMS_MULTIPROCESSING)
302 
312  Thread_queue_MP_callout mp_callout;
313 #endif
314 };
315 
319 typedef struct {
320 #if defined(RTEMS_SMP)
321 
327  Chain_Node Node;
328 #endif
329 
334 
341 
355 typedef struct _Thread_queue_Heads {
359  union {
368 
369 #if !defined(RTEMS_SMP)
370 
374 #endif
375  } Heads;
376 
382 
388 
389 #if defined(RTEMS_SMP)
390 
393  Thread_queue_Priority_queue Priority[ RTEMS_ZERO_LENGTH_ARRAY ];
394 #endif
396 
410 #if defined(RTEMS_SMP)
411  SMP_ticket_lock_Control Lock;
412 #endif
413 
422 
427 
431  const char *name;
432 };
433 
444  Thread_queue_Queue *queue,
445  Priority_Actions *priority_actions
446 );
447 
459  Thread_queue_Queue *queue,
460  Thread_Control *the_thread,
461  Thread_queue_Context *queue_context
462 );
463 
471  Thread_queue_Queue *queue,
472  Thread_Control *the_thread,
473  Thread_queue_Context *queue_context
474 );
475 
487 typedef Thread_Control *( *Thread_queue_Surrender_operation )(
488  Thread_queue_Queue *queue,
489  Thread_queue_Heads *heads,
490  Thread_Control *previous_owner,
491  Thread_queue_Context *queue_context
492 );
493 
503 typedef Thread_Control *( *Thread_queue_First_operation )(
504  Thread_queue_Heads *heads
505 );
506 
517 
524 
531 
536 
541 };
542 
547 typedef struct {
548 #if defined(RTEMS_SMP)
549 #if defined(RTEMS_DEBUG)
550 
561  uint32_t owner;
562 #endif
563 
564 #if defined(RTEMS_PROFILING)
565 
571  SMP_lock_Stats Lock_stats;
572 #endif
573 #endif
574 
580 
583 #ifdef __cplusplus
584 }
585 #endif
586 
587 #endif
588 /* end of include file */
Watchdog_Interval ticks
The timeout in ticks.
Definition: threadq.h:227
Thread_Control * owner
The thread queue owner.
Definition: threadq.h:426
The priority aggregation.
Definition: priority.h:129
Definition: chain.h:65
Definition: threadq.h:120
Thread queue context for the thread queue methods.
Definition: threadq.h:193
Priority_Actions Actions
A priority action list.
Definition: threadq.h:273
Thread_queue_Enqueue_callout enqueue_callout
The enqueue callout for _Thread_queue_Enqueue().
Definition: threadq.h:216
Thread priority queue.
Definition: threadq.h:319
Constants and Structures Associated with the Object Handler.
Thread_queue_Deadlock_callout deadlock_callout
Invoked in case of a detected deadlock.
Definition: threadq.h:299
A list of priority actions.
Definition: priority.h:189
Definition: chain.h:83
Thread Execution State Information.
Definition: threadq.h:547
struct _Thread_queue_Heads Thread_queue_Heads
Thread queue heads.
void(* Thread_queue_Priority_actions_operation)(Thread_queue_Queue *queue, Priority_Actions *priority_actions)
Thread queue action operation.
Definition: threadq.h:443
Thread_queue_First_operation first
Thread queue first operation.
Definition: threadq.h:540
void(* Thread_queue_Deadlock_callout)(Thread_Control *the_thread)
Thread queue deadlock callout.
Definition: threadq.h:81
Red-black tree node.
Definition: rbtree.h:50
Thread_queue_Priority_queue Priority
This is the set of threads for priority discipline waiting.
Definition: threadq.h:373
Definition: threadq.h:397
Thread queue operations.
Definition: threadq.h:512
size_t update_count
Count of threads to update the priority via _Thread_Priority_update().
Definition: threadq.h:279
Thread_queue_Queue Queue
The actual thread queue.
Definition: threadq.h:578
Thread_queue_Heads * heads
Lock to protect this thread queue.
Definition: threadq.h:421
Thread queue heads.
Definition: threadq.h:355
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:381
Priority_Aggregation Queue
The actual thread priority queue.
Definition: threadq.h:333
Thread_queue_Surrender_operation surrender
Thread queue surrender operation.
Definition: threadq.h:535
Definition: thread.h:728
Per CPU Core Structure.
Definition: percpu.h:290
const char * name
The thread queue name.
Definition: threadq.h:431
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:198
Thread_queue_Priority_actions_operation priority_actions
Thread queue priority actions operation.
Definition: threadq.h:516
Thread_Control *(* Thread_queue_First_operation)(Thread_queue_Heads *heads)
Thread queue first operation.
Definition: threadq.h:503
Thread_queue_Extract_operation extract
Thread queue extract operation.
Definition: threadq.h:530
void(* Thread_queue_Extract_operation)(Thread_queue_Queue *queue, Thread_Control *the_thread, Thread_queue_Context *queue_context)
Thread queue extract operation.
Definition: threadq.h:470
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:67
Constants and Structures Associated with the Red-Black Tree Handler.
Priority Handler API.
uint32_t States_Control
Definition: states.h:41
States_Control thread_state
The thread state for _Thread_queue_Enqueue().
Definition: threadq.h:203
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdogticks.h:36
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:387
Thread_queue_Enqueue_operation enqueue
Thread queue enqueue operation.
Definition: threadq.h:523
Chain Handler API.
Scheduler node for per-thread data.
Definition: schedulernode.h:65
struct Scheduler_Node * scheduler_node
This priority queue is added to a scheduler node of the owner in case of priority inheritance...
Definition: threadq.h:339
const void * arg
The timeout argument, e.g. pointer to struct timespec.
Definition: threadq.h:232
void(* Thread_queue_Enqueue_operation)(Thread_queue_Queue *queue, Thread_Control *the_thread, Thread_queue_Context *queue_context)
Thread queue enqueue operation.
Definition: threadq.h:458
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:125
uint32_t Objects_Id
Definition: object.h:75
Chain_Control Fifo
This is the FIFO discipline list.
Definition: threadq.h:367
ISR Locks.
Thread_Control *(* Thread_queue_Surrender_operation)(Thread_queue_Queue *queue, Thread_queue_Heads *heads, Thread_Control *previous_owner, Thread_queue_Context *queue_context)
Thread queue surrender operation.
Definition: threadq.h:487