RTEMS 6.1-rc1
threads.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * Copyright (C) 2020 embedded brains GmbH & Co. KG
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _RTEMS_CONFDEFS_THREADS_H
38#define _RTEMS_CONFDEFS_THREADS_H
39
40#ifndef __CONFIGURATION_TEMPLATE_h
41#error "Do not include this file directly, use <rtems/confdefs.h> instead"
42#endif
43
44#ifdef CONFIGURE_INIT
45
51#include <rtems/score/thread.h>
53
54#ifdef RTEMS_POSIX_API
56#endif
57
58#ifndef CONFIGURE_MAXIMUM_TASKS
59 #define CONFIGURE_MAXIMUM_TASKS 0
60#endif
61
62#define _CONFIGURE_TASKS ( CONFIGURE_MAXIMUM_TASKS + _CONFIGURE_LIBBLOCK_TASKS )
63
64#ifndef CONFIGURE_MINIMUM_TASKS_WITH_USER_PROVIDED_STORAGE
65 #define CONFIGURE_MINIMUM_TASKS_WITH_USER_PROVIDED_STORAGE 0
66#endif
67
68#if CONFIGURE_MINIMUM_TASKS_WITH_USER_PROVIDED_STORAGE > CONFIGURE_MAXIMUM_TASKS
69 #error "CONFIGURE_MINIMUM_TASKS_WITH_USER_PROVIDED_STORAGE shall be less than or equal to CONFIGURE_MAXIMUM_TASKS"
70#endif
71
72#ifndef CONFIGURE_MAXIMUM_POSIX_THREADS
73 #define CONFIGURE_MAXIMUM_POSIX_THREADS 0
74#endif
75
76#if CONFIGURE_MAXIMUM_POSIX_THREADS > 0
77 #include <rtems/posix/pthread.h>
78#endif
79
80#if !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) \
81 && CONFIGURE_MAXIMUM_TASKS == 0 \
82 && CONFIGURE_MAXIMUM_POSIX_THREADS == 0
83 #error "You must define one of CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION, CONFIGURE_MAXIMUM_TASKS, and CONFIGURE_MAXIMUM_POSIX_THREADS"
84#endif
85
86#if !defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE) \
87 && !defined(CONFIGURE_POSIX_INIT_THREAD_TABLE) \
88 && !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION)
89 #error "You must define one of CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION, CONFIGURE_RTEMS_INIT_TASKS_TABLE, and CONFIGURE_POSIX_INIT_THREAD_TABLE"
90#endif
91
92#ifndef CONFIGURE_MAXIMUM_THREAD_NAME_SIZE
93 #define CONFIGURE_MAXIMUM_THREAD_NAME_SIZE THREAD_DEFAULT_MAXIMUM_NAME_SIZE
94#endif
95
96#ifndef CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE
97 #define CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE 0
98#endif
99
100#ifdef __cplusplus
101extern "C" {
102#endif
103
104typedef union {
105 Scheduler_Node Base;
106 #ifdef CONFIGURE_SCHEDULER_CBS
108 #endif
109 #ifdef CONFIGURE_SCHEDULER_EDF
111 #endif
112 #ifdef CONFIGURE_SCHEDULER_EDF_SMP
114 #endif
115 #ifdef CONFIGURE_SCHEDULER_PRIORITY
117 #endif
118 #ifdef CONFIGURE_SCHEDULER_SIMPLE_SMP
119 Scheduler_SMP_Node Simple_SMP;
120 #endif
121 #ifdef CONFIGURE_SCHEDULER_PRIORITY_SMP
122 Scheduler_priority_SMP_Node Priority_SMP;
123 #endif
124 #ifdef CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP
125 Scheduler_priority_affinity_SMP_Node Priority_affinity_SMP;
126 #endif
127 #ifdef CONFIGURE_SCHEDULER_STRONG_APA
128 Scheduler_strong_APA_Node Strong_APA;
129 #endif
130 #ifdef CONFIGURE_SCHEDULER_USER_PER_THREAD
131 CONFIGURE_SCHEDULER_USER_PER_THREAD User;
132 #endif
133} Configuration_Scheduler_node;
134
135#ifdef RTEMS_SMP
136 const size_t _Scheduler_Node_size = sizeof( Configuration_Scheduler_node );
137#endif
138
140
144);
145
146const size_t _Thread_Maximum_TLS_size =
148
150/*
151 * This was added to address the following warning.
152 * warning: invalid use of structure with flexible array member
153 */
154#pragma GCC diagnostic push
155#pragma GCC diagnostic ignored "-Wpedantic"
156 Thread_Control Control;
157#pragma GCC diagnostic pop
158
159 #if CONFIGURE_MAXIMUM_USER_EXTENSIONS > 0
160 void *extensions[ CONFIGURE_MAXIMUM_USER_EXTENSIONS + 1 ];
161 #endif
162 Configuration_Scheduler_node Scheduler_nodes[ _CONFIGURE_SCHEDULER_COUNT ];
163 RTEMS_API_Control API_RTEMS;
164 #ifdef RTEMS_POSIX_API
165 POSIX_API_Control API_POSIX;
166 #endif
167 #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1
169 #endif
170 #if defined(_CONFIGURE_ENABLE_NEWLIB_REENTRANCY) && \
171 !defined(_REENT_THREAD_LOCAL)
172 struct _reent Newlib;
173 #endif
174};
175
177 {
178 offsetof( Thread_Configured_control, Control.Scheduler.nodes ),
179 offsetof( Thread_Configured_control, Scheduler_nodes )
180 }, {
181 offsetof(
183 Control.API_Extensions[ THREAD_API_RTEMS ]
184 ),
185 offsetof( Thread_Configured_control, API_RTEMS )
186 }
187 #if defined(_CONFIGURE_ENABLE_NEWLIB_REENTRANCY) && \
188 !defined(_REENT_THREAD_LOCAL)
189 , {
190 offsetof(
192 Control.libc_reent
193 ),
194 offsetof( Thread_Configured_control, Newlib )
195 }
196 #endif
197 #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1
198 , {
199 offsetof(
201 Control.Join_queue.Queue.name
202 ),
203 offsetof( Thread_Configured_control, name )
204 }
205 #endif
206 #ifdef RTEMS_POSIX_API
207 , {
208 offsetof(
210 Control.API_Extensions[ THREAD_API_POSIX ]
211 ),
212 offsetof( Thread_Configured_control, API_POSIX )
213 }
214 #endif
215};
216
217const size_t _Thread_Control_add_on_count =
219
220#ifdef RTEMS_SMP
222/*
223 * This was put in to address the following warning.
224 * warning: invalid use of structure with flexible array member
225 */
226#pragma GCC diagnostic push
227#pragma GCC diagnostic ignored "-Wpedantic"
229#pragma GCC diagnostic pop
230 Thread_queue_Priority_queue Priority[ _CONFIGURE_SCHEDULER_COUNT ];
231 };
232
233 const size_t _Thread_queue_Heads_size =
235#endif
236
237const size_t _Thread_Initial_thread_count =
238#if !defined(CONFIGURE_IDLE_TASK_STORAGE_SIZE) && \
239 !defined(CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE)
240 _CONFIGURE_MAXIMUM_PROCESSORS +
241#endif
242 rtems_resource_maximum_per_allocation( _CONFIGURE_TASKS ) +
244
245#if defined(RTEMS_MULTIPROCESSING) && defined(CONFIGURE_MP_APPLICATION)
246 #define _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT 1
247#else
248 #define _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT 0
249#endif
250
251THREAD_INFORMATION_DEFINE(
252 _Thread,
253 OBJECTS_INTERNAL_API,
254 OBJECTS_INTERNAL_THREADS,
255 _CONFIGURE_MAXIMUM_PROCESSORS + _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT
256);
257
258#if _CONFIGURE_TASKS > 0
259 THREAD_INFORMATION_DEFINE(
260 _RTEMS_tasks,
261 OBJECTS_CLASSIC_API,
262 OBJECTS_RTEMS_TASKS,
263 _CONFIGURE_TASKS
264 );
265#endif
266
267#if CONFIGURE_MAXIMUM_POSIX_THREADS > 0
268 const size_t _POSIX_Threads_Minimum_stack_size =
270
271 THREAD_INFORMATION_DEFINE(
272 _POSIX_Threads,
273 OBJECTS_POSIX_API,
274 OBJECTS_POSIX_THREADS,
276 );
277#endif
278
279#ifdef __cplusplus
280}
281#endif
282
283#endif /* CONFIGURE_INIT */
284
285#endif /* _RTEMS_CONFDEFS_THREADS_H */
This header file evaluates configuration options related to the block device cache configuration.
This header file evaluates configuration options related to the per-CPU configuration.
This header file evaluates configuration options related to the scheduler configuration.
This header file evaluates configuration options related to the user extensions configuration.
#define RTEMS_STATIC_ASSERT(_cond, _msg)
It is defined if a static analysis run is performed.
Definition: basedefs.h:841
#define RTEMS_ARRAY_SIZE(_array)
Gets the element count of the array.
Definition: basedefs.h:244
#define RTEMS_TASK_STORAGE_ALIGNMENT
This compile time constant defines the recommended alignment of a task storage area in bytes.
Definition: tasks.h:365
#define rtems_resource_maximum_per_allocation(_resource)
Gets the maximum number per allocation of a resource number.
Definition: config.h:890
#define CONFIGURE_MAXIMUM_USER_EXTENSIONS
This configuration option is an integer define.
Definition: appl-config.h:835
#define CONFIGURE_MAXIMUM_THREAD_NAME_SIZE
This configuration option is an integer define.
Definition: appl-config.h:3020
#define CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE
This configuration option is an integer define.
Definition: appl-config.h:2979
#define CONFIGURE_MAXIMUM_POSIX_THREADS
This configuration option is an integer define.
Definition: appl-config.h:4212
#define CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE
This configuration option is an integer define.
Definition: appl-config.h:4291
const size_t _Thread_Initial_thread_count
Count of configured threads.
const size_t _Thread_Maximum_TLS_size
If this constant is greater than zero, then it defines the maximum thread-local storage size,...
#define _Thread_queue_Heads_size
Size of the thread queue heads of a particular application.
Definition: thread.h:1092
const Thread_Control_add_on _Thread_Control_add_ons[]
Thread control add-ons.
const size_t _Thread_Control_add_on_count
Thread control add-on count.
Thread_queue_Heads Thread_queue_Configured_heads
The configured thread queue heads.
Definition: thread.h:1081
struct Thread_Configured_control Thread_Configured_control
The configured thread control block.
Definition: thread.h:1070
const size_t _Thread_Maximum_name_size
Maximum size of a thread name in characters (including the terminating '\0' character).
@ THREAD_API_POSIX
Definition: thread.h:631
@ THREAD_API_RTEMS
Definition: thread.h:629
POSIX Threads Private Support.
This header file provides interfaces of the Thread Handler which are used by the implementation and t...
Definition: tasksdata.h:63
Definition: schedulercbs.h:156
Scheduler node specialization for EDF schedulers.
Definition: scheduleredf.h:107
Definition: scheduleredfsmp.h:59
Scheduler node for per-thread data.
Definition: schedulernode.h:94
Scheduler node specialization for SMP schedulers.
Definition: schedulersmp.h:106
Scheduler node specialization for Deterministic Priority schedulers.
Definition: schedulerpriority.h:119
Scheduler node specialization for Deterministic Priority SMP schedulers.
Definition: schedulerprioritysmp.h:82
Scheduler node specialization for Deterministic Priority Affinity SMP schedulers.
Definition: schedulerpriorityaffinitysmp.h:288
Scheduler node specialization for Strong APA schedulers.
Definition: schedulerstrongapa.h:74
Thread control add-on.
Definition: thread.h:991
Thread priority queue.
Definition: threadq.h:349
Definition: thread.h:812
Thread queue heads.
Definition: threadq.h:385
union _Thread_queue_Heads::@4389 Heads
This header file provides data structures used by the implementation and the Application Configuratio...
POSIX Thread API Support.
This header file evaluates configuration options related to the unlimited objects configuration.