RTEMS  5.1-rc2
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>
47 #include <rtems/confdefs/mpci.h>
48 #include <rtems/confdefs/percpu.h>
51 #include <rtems/score/thread.h>
52 #include <rtems/posix/threadsup.h>
53 #include <rtems/rtems/tasksdata.h>
54 
55 #ifndef CONFIGURE_MAXIMUM_TASKS
56  #define CONFIGURE_MAXIMUM_TASKS 0
57 #endif
58 
59 #define _CONFIGURE_TASKS ( CONFIGURE_MAXIMUM_TASKS + _CONFIGURE_LIBBLOCK_TASKS )
60 
61 #ifndef CONFIGURE_MAXIMUM_POSIX_THREADS
62  #define CONFIGURE_MAXIMUM_POSIX_THREADS 0
63 #endif
64 
65 #if CONFIGURE_MAXIMUM_POSIX_THREADS > 0
66  #include <rtems/posix/pthread.h>
67 #endif
68 
69 #if !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) \
70  && CONFIGURE_MAXIMUM_TASKS == 0 \
71  && CONFIGURE_MAXIMUM_POSIX_THREADS == 0
72  #error "You must define one of CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION, CONFIGURE_MAXIMUM_TASKS, and CONFIGURE_MAXIMUM_POSIX_THREADS"
73 #endif
74 
75 #if !defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE) \
76  && !defined(CONFIGURE_POSIX_INIT_THREAD_TABLE) \
77  && !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION)
78  #error "You must define one of CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION, CONFIGURE_RTEMS_INIT_TASKS_TABLE, and CONFIGURE_POSIX_INIT_THREAD_TABLE"
79 #endif
80 
81 #ifndef CONFIGURE_MAXIMUM_THREAD_NAME_SIZE
82  #define CONFIGURE_MAXIMUM_THREAD_NAME_SIZE THREAD_DEFAULT_MAXIMUM_NAME_SIZE
83 #endif
84 
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
88 
89 typedef union {
90  Scheduler_Node Base;
91  #ifdef CONFIGURE_SCHEDULER_CBS
93  #endif
94  #ifdef CONFIGURE_SCHEDULER_EDF
96  #endif
97  #ifdef CONFIGURE_SCHEDULER_EDF_SMP
98  Scheduler_EDF_SMP_Node EDF_SMP;
99  #endif
100  #ifdef CONFIGURE_SCHEDULER_PRIORITY
101  Scheduler_priority_Node Priority;
102  #endif
103  #ifdef CONFIGURE_SCHEDULER_SIMPLE_SMP
104  Scheduler_SMP_Node Simple_SMP;
105  #endif
106  #ifdef CONFIGURE_SCHEDULER_PRIORITY_SMP
107  Scheduler_priority_SMP_Node Priority_SMP;
108  #endif
109  #ifdef CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP
110  Scheduler_priority_affinity_SMP_Node Priority_affinity_SMP;
111  #endif
112  #ifdef CONFIGURE_SCHEDULER_STRONG_APA
113  Scheduler_strong_APA_Node Strong_APA;
114  #endif
115  #ifdef CONFIGURE_SCHEDULER_USER_PER_THREAD
116  CONFIGURE_SCHEDULER_USER_PER_THREAD User;
117  #endif
118 } Configuration_Scheduler_node;
119 
120 #ifdef RTEMS_SMP
121  const size_t _Scheduler_Node_size = sizeof( Configuration_Scheduler_node );
122 #endif
123 
124 const size_t _Thread_Maximum_name_size = CONFIGURE_MAXIMUM_THREAD_NAME_SIZE;
125 
127  Thread_Control Control;
128  #if CONFIGURE_MAXIMUM_USER_EXTENSIONS > 0
129  void *extensions[ CONFIGURE_MAXIMUM_USER_EXTENSIONS + 1 ];
130  #endif
131  Configuration_Scheduler_node Scheduler_nodes[ _CONFIGURE_SCHEDULER_COUNT ];
132  RTEMS_API_Control API_RTEMS;
133  #ifdef RTEMS_POSIX_API
134  POSIX_API_Control API_POSIX;
135  #endif
136  #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1
137  char name[ CONFIGURE_MAXIMUM_THREAD_NAME_SIZE ];
138  #endif
139  #ifdef _CONFIGURE_ENABLE_NEWLIB_REENTRANCY
140  struct _reent Newlib;
141  #else
142  struct { /* Empty */ } Newlib;
143  #endif
144 };
145 
147  {
148  offsetof( Thread_Configured_control, Control.Scheduler.nodes ),
149  offsetof( Thread_Configured_control, Scheduler_nodes )
150  }, {
151  offsetof(
153  Control.API_Extensions[ THREAD_API_RTEMS ]
154  ),
155  offsetof( Thread_Configured_control, API_RTEMS )
156  }, {
157  offsetof(
159  Control.libc_reent
160  ),
161  offsetof( Thread_Configured_control, Newlib )
162  }
163  #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1
164  , {
165  offsetof(
167  Control.Join_queue.Queue.name
168  ),
169  offsetof( Thread_Configured_control, name )
170  }
171  #endif
172  #ifdef RTEMS_POSIX_API
173  , {
174  offsetof(
176  Control.API_Extensions[ THREAD_API_POSIX ]
177  ),
178  offsetof( Thread_Configured_control, API_POSIX )
179  }
180  #endif
181 };
182 
183 const size_t _Thread_Control_add_on_count =
184  RTEMS_ARRAY_SIZE( _Thread_Control_add_ons );
185 
186 #ifdef RTEMS_SMP
189  Thread_queue_Priority_queue Priority[ _CONFIGURE_SCHEDULER_COUNT ];
190  };
191 
192  const size_t _Thread_queue_Heads_size =
194 #endif
195 
196 const size_t _Thread_Initial_thread_count =
197  rtems_resource_maximum_per_allocation( _CONFIGURE_TASKS ) +
198  rtems_resource_maximum_per_allocation( CONFIGURE_MAXIMUM_POSIX_THREADS );
199 
200 THREAD_INFORMATION_DEFINE(
201  _Thread,
202  OBJECTS_INTERNAL_API,
203  OBJECTS_INTERNAL_THREADS,
204  _CONFIGURE_MAXIMUM_PROCESSORS + _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT
205 );
206 
207 #if _CONFIGURE_TASKS > 0
208  THREAD_INFORMATION_DEFINE(
209  _RTEMS_tasks,
210  OBJECTS_CLASSIC_API,
211  OBJECTS_RTEMS_TASKS,
212  _CONFIGURE_TASKS
213  );
214 #endif
215 
216 #if CONFIGURE_MAXIMUM_POSIX_THREADS > 0
217  const size_t _POSIX_Threads_Minimum_stack_size =
218  CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE;
219 
220  THREAD_INFORMATION_DEFINE(
221  _POSIX_Threads,
222  OBJECTS_POSIX_API,
223  OBJECTS_POSIX_THREADS,
224  CONFIGURE_MAXIMUM_POSIX_THREADS
225  );
226 #endif
227 
228 #ifdef __cplusplus
229 }
230 #endif
231 
232 #endif /* CONFIGURE_INIT */
233 
234 #endif /* _RTEMS_CONFDEFS_THREADS_H */
Definition: tasksdata.h:41
union _Thread_queue_Heads::@3986 Heads
Scheduler node specialization for EDF schedulers.
Definition: scheduleredf.h:90
Thread priority queue.
Definition: threadq.h:324
Evaluate Per-CPU Configuration Options.
Definition: thread.h:593
Evaluate Unlimited Objects Configuration Options.
Evaluate Scheduler Configuration Options.
POSIX Threads Private Support.
POSIX Thread API Support.
Thread_queue_Priority_queue Priority
This is the set of threads for priority discipline waiting.
Definition: threadq.h:378
#define _Thread_queue_Heads_size
Size of the thread queue heads of a particular application.
Definition: thread.h:991
const size_t _Thread_Control_add_on_count
Thread control add-on count.
const Thread_Control_add_on _Thread_Control_add_ons[]
Thread control add-ons.
Evaluate MPCI Configuration Options.
Thread queue heads.
Definition: threadq.h:360
Definition: scheduleredfsmp.h:38
Definition: thread.h:732
Evaluate User Extensions Configuration Options.
Thread control add-on.
Definition: thread.h:900
Scheduler node specialization for SMP schedulers.
Definition: schedulersmp.h:100
Scheduler node specialization for Deterministic Priority schedulers.
Definition: schedulerpriority.h:101
Scheduler node specialization for Strong APA schedulers.
Definition: schedulerstrongapa.h:66
Scheduler node for per-thread data.
Definition: schedulernode.h:79
Scheduler node specialization for Deterministic Priority SMP schedulers.
Definition: schedulerprioritysmp.h:66
Definition: thread.h:591
Definition: schedulercbs.h:138
Thread_queue_Heads Thread_queue_Configured_heads
The configured thread queue heads.
Definition: thread.h:980
Evaluate Block Device Cache Configuration Options.
Constants and Structures Related with the Thread Control Block.
struct Thread_Configured_control Thread_Configured_control
The configured thread control block.
Definition: thread.h:969
Scheduler node specialization for Deterministic Priority Affinity SMP schedulers.
Definition: schedulerpriorityaffinitysmp.h:230
const size_t _Thread_Initial_thread_count
Count of configured threads.
const size_t _Thread_Maximum_name_size
Maximum size of a thread name in characters (including the terminating '\0' character).
Classic Tasks Manager Data Structures.