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

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
threadq.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_THREADQ_H
22#define _RTEMS_SCORE_THREADQ_H
23
24#include <rtems/score/chain.h>
25#include <rtems/score/isrlock.h>
26#include <rtems/score/object.h>
27#include <rtems/score/priority.h>
28#include <rtems/score/rbtree.h>
29#include <rtems/score/states.h>
30#include <rtems/score/watchdogticks.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36struct Per_CPU_Control;
37
38struct Scheduler_Node;
39
54typedef struct _Thread_Control Thread_Control;
55
56typedef struct Thread_queue_Context Thread_queue_Context;
57
58typedef struct Thread_queue_Queue Thread_queue_Queue;
59
60typedef struct Thread_queue_Operations Thread_queue_Operations;
61
72 typedef void ( *Thread_queue_Enqueue_callout )(
73 Thread_queue_Queue *queue,
74 Thread_Control *the_thread,
75 struct Per_CPU_Control *cpu_self,
76 Thread_queue_Context *queue_context
77);
78
86 typedef void ( *Thread_queue_Deadlock_callout )(
87 Thread_Control *the_thread
88);
89
90#if defined(RTEMS_MULTIPROCESSING)
101typedef void ( *Thread_queue_MP_callout )(
102 Thread_Control *the_proxy,
103 Objects_Id mp_id
104);
105#endif
106
107#if defined(RTEMS_SMP)
118typedef struct {
119 Chain_Node Node;
120
121 Atomic_Uint go_ahead;
122} Thread_queue_Gate;
123#endif
124
125 typedef struct {
130 ISR_lock_Context Lock_context;
131
132#if defined(RTEMS_SMP)
136 struct {
142 Thread_queue_Gate Gate;
143
147 Thread_queue_Queue *queue;
148 } Wait;
149#endif
150} Thread_queue_Lock_context;
151
152#if defined(RTEMS_SMP)
157typedef struct {
162 RBTree_Node Registry_node;
163
167 Thread_queue_Queue *source;
168
173 Thread_queue_Queue *target;
174
178 Chain_Node Path_node;
179
183 Thread_Control *owner;
184
189 Thread_queue_Lock_context Lock_context;
190} Thread_queue_Link;
191#endif
192
198 struct Thread_queue_Context {
203 Thread_queue_Lock_context Lock_context;
204
208 States_Control thread_state;
209
221 Thread_queue_Enqueue_callout enqueue_callout;
222
228 union {
232 Watchdog_Interval ticks;
233
237 const void *arg;
238 } Timeout;
239
240#if defined(RTEMS_SMP)
251 struct {
255 Chain_Control Links;
256
260 Thread_queue_Link Start;
261
266 Thread_queue_Link Deadlock;
267 } Path;
268#endif
269
274 struct {
278 Priority_Actions Actions;
279
284 size_t update_count;
285
293 Thread_Control *update[ 2 ];
294 } Priority;
295
304 Thread_queue_Deadlock_callout deadlock_callout;
305
306#if defined(RTEMS_MULTIPROCESSING)
317 Thread_queue_MP_callout mp_callout;
318#endif
319};
320
324 typedef struct {
325#if defined(RTEMS_SMP)
332 Chain_Node Node;
333#endif
334
338 Priority_Aggregation Queue;
339
344 struct Scheduler_Node *scheduler_node;
345} Thread_queue_Priority_queue;
346
360 typedef struct _Thread_queue_Heads {
364 union {
372 Chain_Control Fifo;
373
374#if !defined(RTEMS_SMP)
378 Thread_queue_Priority_queue Priority;
379#endif
380 } Heads;
381
386 Chain_Control Free_chain;
387
392 Chain_Node Free_node;
393
394#if defined(RTEMS_SMP)
398 Thread_queue_Priority_queue Priority[ RTEMS_ZERO_LENGTH_ARRAY ];
399#endif
400} Thread_queue_Heads;
401
402 struct Thread_queue_Queue {
415#if defined(RTEMS_SMP)
416 SMP_ticket_lock_Control Lock;
417#endif
418
426 Thread_queue_Heads *heads;
427
431 Thread_Control *owner;
432
436 const char *name;
437};
438
448 typedef void ( *Thread_queue_Priority_actions_operation )(
449 Thread_queue_Queue *queue,
450 Priority_Actions *priority_actions
451);
452
463 typedef void ( *Thread_queue_Enqueue_operation )(
464 Thread_queue_Queue *queue,
465 Thread_Control *the_thread,
466 Thread_queue_Context *queue_context
467);
468
475 typedef void ( *Thread_queue_Extract_operation )(
476 Thread_queue_Queue *queue,
477 Thread_Control *the_thread,
478 Thread_queue_Context *queue_context
479);
480
492 typedef Thread_Control *( *Thread_queue_Surrender_operation )(
493 Thread_queue_Queue *queue,
494 Thread_queue_Heads *heads,
495 Thread_Control *previous_owner,
496 Thread_queue_Context *queue_context
497);
498
509 typedef Thread_Control *( *Thread_queue_First_operation )(
510 const Thread_queue_Heads *heads
511);
512
518 struct Thread_queue_Operations {
522 Thread_queue_Priority_actions_operation priority_actions;
523
529 Thread_queue_Enqueue_operation enqueue;
530
536 Thread_queue_Extract_operation extract;
537
541 Thread_queue_Surrender_operation surrender;
542
546 Thread_queue_First_operation first;
547};
548
553 typedef struct {
554#if defined(RTEMS_SMP)
555#if defined(RTEMS_DEBUG)
567 uint32_t owner;
568#endif
569
570#if defined(RTEMS_PROFILING)
577 SMP_lock_Stats Lock_stats;
578#endif
579#endif
580
584 Thread_queue_Queue Queue;
585} Thread_queue_Control;
586
589#ifdef __cplusplus
590}
591#endif
592
593#endif
594/* end of include file */
Objects_Id
uint32_t Objects_Id
Definition: object.h:80
States_Control
uint32_t States_Control
Definition: states.h:46
Thread_queue_First_operation
Thread_Control *(* Thread_queue_First_operation)(const Thread_queue_Heads *heads)
Gets the first thread on the queue.
Definition: threadq.h:509
Thread_queue_Surrender_operation
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:492
Thread_queue_Enqueue_operation
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:463
Thread_queue_Extract_operation
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:475
Thread_queue_Priority_actions_operation
void(* Thread_queue_Priority_actions_operation)(Thread_queue_Queue *queue, Priority_Actions *priority_actions)
Thread queue action operation.
Definition: threadq.h:448
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_Deadlock_callout
void(* Thread_queue_Deadlock_callout)(Thread_Control *the_thread)
Thread queue deadlock callout.
Definition: threadq.h:86
Thread_queue_Heads
struct _Thread_queue_Heads Thread_queue_Heads
Thread queue heads.
Watchdog_Interval
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdogticks.h:38
isrlock.h
ISR Locks.
priority.h
Priority Handler API.
rbtree.h
Constants and Structures Associated with the Red-Black Tree Handler.
chain.h
Chain Handler API.
object.h
Constants and Structures Associated with the Object Handler.
states.h
Thread Execution State Information.
Chain_Node_struct
Definition: chain.h:68
ISR_lock_Context
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
Per_CPU_Control
Per CPU Core Structure.
Definition: percpu.h:347
Priority_Actions
A list of priority actions.
Definition: priority.h:193
Priority_Aggregation
The priority aggregation.
Definition: priority.h:133
RBTree_Node
Red-black tree node.
Definition: rbtree.h:55
Scheduler_Node
Scheduler node for per-thread data.
Definition: schedulernode.h:79
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::Actions
Priority_Actions Actions
A priority action list.
Definition: threadq.h:278
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
Definition: threadq.h:125
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_Operations
Thread queue operations.
Definition: threadq.h:518
Thread_queue_Operations::surrender
Thread_queue_Surrender_operation surrender
Thread queue surrender operation.
Definition: threadq.h:541
Thread_queue_Operations::first
Thread_queue_First_operation first
Thread queue first operation.
Definition: threadq.h:546
Thread_queue_Operations::extract
Thread_queue_Extract_operation extract
Thread queue extract operation.
Definition: threadq.h:536
Thread_queue_Operations::enqueue
Thread_queue_Enqueue_operation enqueue
Thread queue enqueue operation.
Definition: threadq.h:529
Thread_queue_Operations::priority_actions
Thread_queue_Priority_actions_operation priority_actions
Thread queue priority actions operation.
Definition: threadq.h:522
Thread_queue_Priority_queue
Thread priority queue.
Definition: threadq.h:324
Thread_queue_Priority_queue::scheduler_node
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:344
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_Control
Definition: thread.h:732
_Thread_queue_Heads
Thread queue heads.
Definition: threadq.h:360
_Thread_queue_Heads::Fifo
Chain_Control Fifo
This is the FIFO discipline list.
Definition: threadq.h:372
_Thread_queue_Heads::Heads
union _Thread_queue_Heads::@3987 Heads
_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
Chain_Control
Definition: chain.h:86
watchdogticks.h
Constants for the watchdog ticks.