RTEMS: cpukit/include/rtems/confdefs/threads.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
threads.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifndef _RTEMS_CONFDEFS_THREADS_H
37#define _RTEMS_CONFDEFS_THREADS_H
38
39#ifndef __CONFIGURATION_TEMPLATE_h
40#error "Do not include this file directly, use <rtems/confdefs.h> instead"
41#endif
42
43#ifdef CONFIGURE_INIT
44
45#include <rtems/confdefs/bdbuf.h>
46#include <rtems/confdefs/extensions.h>
47#include <rtems/confdefs/percpu.h>
48#include <rtems/confdefs/scheduler.h>
49#include <rtems/confdefs/unlimited.h>
50#include <rtems/score/thread.h>
51#include <rtems/posix/threadsup.h>
52#include <rtems/rtems/tasksdata.h>
53
54#ifndef CONFIGURE_MAXIMUM_TASKS
55 #define CONFIGURE_MAXIMUM_TASKS 0
56#endif
57
58#define _CONFIGURE_TASKS ( CONFIGURE_MAXIMUM_TASKS + _CONFIGURE_LIBBLOCK_TASKS )
59
60#ifndef CONFIGURE_MAXIMUM_POSIX_THREADS
61 #define CONFIGURE_MAXIMUM_POSIX_THREADS 0
62#endif
63
64#if CONFIGURE_MAXIMUM_POSIX_THREADS > 0
65 #include <rtems/posix/pthread.h>
66#endif
67
68#if !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) \
69 && CONFIGURE_MAXIMUM_TASKS == 0 \
70 && CONFIGURE_MAXIMUM_POSIX_THREADS == 0
71 #error "You must define one of CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION, CONFIGURE_MAXIMUM_TASKS, and CONFIGURE_MAXIMUM_POSIX_THREADS"
72#endif
73
74#if !defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE) \
75 && !defined(CONFIGURE_POSIX_INIT_THREAD_TABLE) \
76 && !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION)
77 #error "You must define one of CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION, CONFIGURE_RTEMS_INIT_TASKS_TABLE, and CONFIGURE_POSIX_INIT_THREAD_TABLE"
78#endif
79
80#ifndef CONFIGURE_MAXIMUM_THREAD_NAME_SIZE
81 #define CONFIGURE_MAXIMUM_THREAD_NAME_SIZE THREAD_DEFAULT_MAXIMUM_NAME_SIZE
82#endif
83
84#ifdef __cplusplus
85extern "C" {
86#endif
87
88typedef union {
89 Scheduler_Node Base;
90 #ifdef CONFIGURE_SCHEDULER_CBS
91 Scheduler_CBS_Node CBS;
92 #endif
93 #ifdef CONFIGURE_SCHEDULER_EDF
94 Scheduler_EDF_Node EDF;
95 #endif
96 #ifdef CONFIGURE_SCHEDULER_EDF_SMP
97 Scheduler_EDF_SMP_Node EDF_SMP;
98 #endif
99 #ifdef CONFIGURE_SCHEDULER_PRIORITY
100 Scheduler_priority_Node Priority;
101 #endif
102 #ifdef CONFIGURE_SCHEDULER_SIMPLE_SMP
103 Scheduler_SMP_Node Simple_SMP;
104 #endif
105 #ifdef CONFIGURE_SCHEDULER_PRIORITY_SMP
106 Scheduler_priority_SMP_Node Priority_SMP;
107 #endif
108 #ifdef CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP
109 Scheduler_priority_affinity_SMP_Node Priority_affinity_SMP;
110 #endif
111 #ifdef CONFIGURE_SCHEDULER_STRONG_APA
112 Scheduler_strong_APA_Node Strong_APA;
113 #endif
114 #ifdef CONFIGURE_SCHEDULER_USER_PER_THREAD
115 CONFIGURE_SCHEDULER_USER_PER_THREAD User;
116 #endif
117} Configuration_Scheduler_node;
118
119#ifdef RTEMS_SMP
120 const size_t _Scheduler_Node_size = sizeof( Configuration_Scheduler_node );
121#endif
122
123const size_t _Thread_Maximum_name_size = CONFIGURE_MAXIMUM_THREAD_NAME_SIZE;
124
125struct Thread_Configured_control {
126 Thread_Control Control;
127 #if CONFIGURE_MAXIMUM_USER_EXTENSIONS > 0
128 void *extensions[ CONFIGURE_MAXIMUM_USER_EXTENSIONS + 1 ];
129 #endif
130 Configuration_Scheduler_node Scheduler_nodes[ _CONFIGURE_SCHEDULER_COUNT ];
131 RTEMS_API_Control API_RTEMS;
132 #ifdef RTEMS_POSIX_API
133 POSIX_API_Control API_POSIX;
134 #endif
135 #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1
136 char name[ CONFIGURE_MAXIMUM_THREAD_NAME_SIZE ];
137 #endif
138 #ifdef _CONFIGURE_ENABLE_NEWLIB_REENTRANCY
139 struct _reent Newlib;
140 #else
141 struct { /* Empty */ } Newlib;
142 #endif
143};
144
145const Thread_Control_add_on _Thread_Control_add_ons[] = {
146 {
147 offsetof( Thread_Configured_control, Control.Scheduler.nodes ),
148 offsetof( Thread_Configured_control, Scheduler_nodes )
149 }, {
150 offsetof(
151 Thread_Configured_control,
152 Control.API_Extensions[ THREAD_API_RTEMS ]
153 ),
154 offsetof( Thread_Configured_control, API_RTEMS )
155 }, {
156 offsetof(
157 Thread_Configured_control,
158 Control.libc_reent
159 ),
160 offsetof( Thread_Configured_control, Newlib )
161 }
162 #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1
163 , {
164 offsetof(
165 Thread_Configured_control,
166 Control.Join_queue.Queue.name
167 ),
168 offsetof( Thread_Configured_control, name )
169 }
170 #endif
171 #ifdef RTEMS_POSIX_API
172 , {
173 offsetof(
174 Thread_Configured_control,
175 Control.API_Extensions[ THREAD_API_POSIX ]
176 ),
177 offsetof( Thread_Configured_control, API_POSIX )
178 }
179 #endif
180};
181
182const size_t _Thread_Control_add_on_count =
183 RTEMS_ARRAY_SIZE( _Thread_Control_add_ons );
184
185#ifdef RTEMS_SMP
186 struct Thread_queue_Configured_heads {
187 Thread_queue_Heads Heads;
188 Thread_queue_Priority_queue Priority[ _CONFIGURE_SCHEDULER_COUNT ];
189 };
190
191 const size_t _Thread_queue_Heads_size =
192 sizeof( Thread_queue_Configured_heads );
193#endif
194
195const size_t _Thread_Initial_thread_count =
196 rtems_resource_maximum_per_allocation( _CONFIGURE_TASKS ) +
197 rtems_resource_maximum_per_allocation( CONFIGURE_MAXIMUM_POSIX_THREADS );
198
199#if defined(RTEMS_MULTIPROCESSING) && defined(CONFIGURE_MP_APPLICATION)
200 #define _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT 1
201#else
202 #define _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT 0
203#endif
204
205THREAD_INFORMATION_DEFINE(
206 _Thread,
207 OBJECTS_INTERNAL_API,
208 OBJECTS_INTERNAL_THREADS,
209 _CONFIGURE_MAXIMUM_PROCESSORS + _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT
210);
211
212#if _CONFIGURE_TASKS > 0
213 THREAD_INFORMATION_DEFINE(
214 _RTEMS_tasks,
215 OBJECTS_CLASSIC_API,
216 OBJECTS_RTEMS_TASKS,
217 _CONFIGURE_TASKS
218 );
219#endif
220
221#if CONFIGURE_MAXIMUM_POSIX_THREADS > 0
222 const size_t _POSIX_Threads_Minimum_stack_size =
223 CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE;
224
225 THREAD_INFORMATION_DEFINE(
226 _POSIX_Threads,
227 OBJECTS_POSIX_API,
228 OBJECTS_POSIX_THREADS,
229 CONFIGURE_MAXIMUM_POSIX_THREADS
230 );
231#endif
232
233#ifdef __cplusplus
234}
235#endif
236
237#endif /* CONFIGURE_INIT */
238
239#endif /* _RTEMS_CONFDEFS_THREADS_H */
bdbuf.h
Evaluate Block Device Cache Configuration Options.
percpu.h
Evaluate Per-CPU Configuration Options.
scheduler.h
Evaluate Scheduler Configuration Options.
extensions.h
Evaluate User Extensions Configuration Options.
_Thread_Initial_thread_count
const size_t _Thread_Initial_thread_count
Count of configured threads.
_Thread_queue_Heads_size
#define _Thread_queue_Heads_size
Size of the thread queue heads of a particular application.
Definition: thread.h:991
_Thread_Control_add_ons
const Thread_Control_add_on _Thread_Control_add_ons[]
Thread control add-ons.
_Thread_Control_add_on_count
const size_t _Thread_Control_add_on_count
Thread control add-on count.
Thread_queue_Configured_heads
Thread_queue_Heads Thread_queue_Configured_heads
The configured thread queue heads.
Definition: thread.h:980
Thread_Configured_control
struct Thread_Configured_control Thread_Configured_control
The configured thread control block.
Definition: thread.h:969
_Thread_Maximum_name_size
const size_t _Thread_Maximum_name_size
Maximum size of a thread name in characters (including the terminating '\0' character).
THREAD_API_POSIX
@ THREAD_API_POSIX
Definition: thread.h:593
THREAD_API_RTEMS
@ THREAD_API_RTEMS
Definition: thread.h:591
pthread.h
POSIX Threads Private Support.
thread.h
Constants and Structures Related with the Thread Control Block.
RTEMS_API_Control
Definition: tasksdata.h:41
Scheduler_CBS_Node
Definition: schedulercbs.h:138
Scheduler_EDF_Node
Scheduler node specialization for EDF schedulers.
Definition: scheduleredf.h:90
Scheduler_EDF_SMP_Node
Definition: scheduleredfsmp.h:38
Scheduler_Node
Scheduler node for per-thread data.
Definition: schedulernode.h:79
Scheduler_SMP_Node
Scheduler node specialization for SMP schedulers.
Definition: schedulersmp.h:100
Scheduler_priority_Node
Scheduler node specialization for Deterministic Priority schedulers.
Definition: schedulerpriority.h:101
Scheduler_priority_SMP_Node
Scheduler node specialization for Deterministic Priority SMP schedulers.
Definition: schedulerprioritysmp.h:66
Scheduler_priority_affinity_SMP_Node
Scheduler node specialization for Deterministic Priority Affinity SMP schedulers.
Definition: schedulerpriorityaffinitysmp.h:230
Scheduler_strong_APA_Node
Scheduler node specialization for Strong APA schedulers.
Definition: schedulerstrongapa.h:66
Thread_Control_add_on
Thread control add-on.
Definition: thread.h:900
Thread_queue_Priority_queue
Thread priority queue.
Definition: threadq.h:324
_Thread_Control
Definition: thread.h:732
_Thread_queue_Heads
Thread queue heads.
Definition: threadq.h:360
tasksdata.h
Classic Tasks Manager Data Structures.
threadsup.h
POSIX Thread API Support.
unlimited.h
Evaluate Unlimited Objects Configuration Options.