RTEMS 6.1-rc5
Loading...
Searching...
No Matches
test-scheduler.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Copyright (C) 2021 embedded brains GmbH & Co. KG
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_TEST_SCHEDULER_H
37#define _RTEMS_TEST_SCHEDULER_H
38
39#include <rtems/test.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
53typedef enum {
54 T_SCHEDULER_NOP,
55 T_SCHEDULER_ADD_PROCESSOR,
56 T_SCHEDULER_ANY,
57 T_SCHEDULER_ASK_FOR_HELP,
58 T_SCHEDULER_BLOCK,
59 T_SCHEDULER_CANCEL_JOB,
60 T_SCHEDULER_CLEAN_STICKY,
61 T_SCHEDULER_INITIALIZE,
62 T_SCHEDULER_MAKE_STICKY,
63 T_SCHEDULER_MAP_PRIORITY,
64 T_SCHEDULER_NODE_DESTROY,
65 T_SCHEDULER_NODE_INITIALIZE,
66 T_SCHEDULER_PIN,
67 T_SCHEDULER_RECONSIDER_HELP_REQUEST,
68 T_SCHEDULER_RELEASE_JOB,
69 T_SCHEDULER_REMOVE_PROCESSOR,
70 T_SCHEDULER_SCHEDULE,
71 T_SCHEDULER_SET_AFFINITY,
72 T_SCHEDULER_START_IDLE,
73 T_SCHEDULER_UNBLOCK,
74 T_SCHEDULER_UNMAP_PRIORITY,
75 T_SCHEDULER_UNPIN,
76 T_SCHEDULER_UPDATE_PRIORITY,
77 T_SCHEDULER_WITHDRAW_NODE,
78 T_SCHEDULER_YIELD
79} T_scheduler_operation;
80
81typedef struct {
82 Thread_Control *executing;
83 uint32_t cpu;
84 T_time instant;
85 T_scheduler_operation operation;
86 Thread_Control *thread;
87 Scheduler_Node *node;
88 union {
89 struct {
92 } map_unmap_priority;
93 struct {
94 bool success;
95 } ask_for_help;
96 struct {
97#ifdef RTEMS_SMP
98 Thread_Scheduler_state next_state;
99#else
100 int next_state;
101#endif
102 } withdraw_node;
103 struct {
104 struct Per_CPU_Control *cpu;
105 } pin_unpin;
106 struct {
107 Thread_Control *idle;
108 } add_processor;
109 struct {
110 struct Per_CPU_Control *cpu;
111 Thread_Control *idle;
112 } remove_processor;
113 struct {
114 Priority_Node *priority;
115 uint64_t deadline;
116 } release_job;
117 struct {
118 Priority_Node *priority;
119 } cancel_job;
120 struct {
121 Processor_mask affinity;
122 Status_Control status;
123 } set_affinity;
124 };
126
127typedef struct {
128 size_t recorded;
129 size_t capacity;
130 uint64_t operations;
132
133typedef struct {
134 T_scheduler_header header;
135 T_scheduler_event events[T_ZERO_LENGTH_ARRAY];
137
138typedef struct {
139 T_scheduler_header header;
140 T_scheduler_event events[2];
142
143typedef struct {
144 T_scheduler_header header;
145 T_scheduler_event events[4];
147
148typedef struct {
149 T_scheduler_header header;
150 T_scheduler_event events[10];
152
153typedef struct {
154 T_scheduler_header header;
155 T_scheduler_event events[20];
157
158typedef struct {
159 T_scheduler_header header;
160 T_scheduler_event events[40];
162
163T_scheduler_log *T_scheduler_record(T_scheduler_log *);
164
165T_scheduler_log *T_scheduler_record_2(T_scheduler_log_2 *);
166
167T_scheduler_log *T_scheduler_record_4(T_scheduler_log_4 *);
168
169T_scheduler_log *T_scheduler_record_10(T_scheduler_log_10 *);
170
171T_scheduler_log *T_scheduler_record_20(T_scheduler_log_20 *);
172
173T_scheduler_log *T_scheduler_record_40(T_scheduler_log_40 *);
174
175typedef enum {
176 T_SCHEDULER_BEFORE,
177 T_SCHEDULER_AFTER
178} T_scheduler_when;
179
180typedef void (*T_scheduler_event_handler)(void *, const T_scheduler_event *,
181 T_scheduler_when);
182
183void T_scheduler_set_event_handler(T_scheduler_event_handler, void *);
184
185extern const T_scheduler_event T_scheduler_event_null;
186
187const T_scheduler_event *T_scheduler_next(T_scheduler_header *,
188 T_scheduler_operation, size_t *);
189
190const T_scheduler_event *T_scheduler_next_any(T_scheduler_header *,
191 size_t *);
192
193void T_scheduler_initialize(const Scheduler_Control *);
194
195void T_scheduler_schedule(const Scheduler_Control *, Thread_Control *);
196
197void T_scheduler_yield(const Scheduler_Control *, Thread_Control *,
199
200void T_scheduler_block(const Scheduler_Control *, Thread_Control *,
202
203void T_scheduler_unblock(const Scheduler_Control *, Thread_Control *,
205
206void T_scheduler_update_priority(const Scheduler_Control *, Thread_Control *,
208
209Priority_Control T_scheduler_map_priority(const Scheduler_Control *,
211
212Priority_Control T_scheduler_unmap_priority(const Scheduler_Control *,
214
215void T_scheduler_node_initialize(const Scheduler_Control *, Scheduler_Node *,
217
218void T_scheduler_node_destroy(const Scheduler_Control *, Scheduler_Node *);
219
220void T_scheduler_release_job(const Scheduler_Control *, Thread_Control *,
221 Priority_Node *, uint64_t, Thread_queue_Context *);
222
223void T_scheduler_cancel_job(const Scheduler_Control *, Thread_Control *,
225
226void T_scheduler_start_idle(const Scheduler_Control *, Thread_Control *,
227 struct Per_CPU_Control *);
228
229#ifdef RTEMS_SMP
230bool T_scheduler_ask_for_help(const Scheduler_Control *, Thread_Control *,
232
233void T_scheduler_reconsider_help_request(const Scheduler_Control *,
235
236void T_scheduler_withdraw_node(const Scheduler_Control *, Thread_Control *,
237 Scheduler_Node *, Thread_Scheduler_state);
238
239void T_scheduler_make_sticky(const Scheduler_Control *, Thread_Control *,
241
242void T_scheduler_clean_sticky(const Scheduler_Control *, Thread_Control *,
244
245void T_scheduler_pin(const Scheduler_Control *, Thread_Control *,
246 Scheduler_Node *, struct Per_CPU_Control *);
247
248void T_scheduler_unpin(const Scheduler_Control *, Thread_Control *,
249 Scheduler_Node *, struct Per_CPU_Control *);
250
251void T_scheduler_add_processor(const Scheduler_Control *, Thread_Control *);
252
253Thread_Control *T_scheduler_remove_processor(const Scheduler_Control *,
254 struct Per_CPU_Control *);
255
256Status_Control T_scheduler_set_affinity(const Scheduler_Control *,
257 Thread_Control *, Scheduler_Node *, const Processor_mask *);
258#endif
259
260#ifdef RTEMS_SMP
261#define T_SCHEDULER_ENTRY_POINTS { T_scheduler_initialize, \
262 T_scheduler_schedule, T_scheduler_yield, T_scheduler_block, \
263 T_scheduler_unblock, T_scheduler_update_priority, \
264 T_scheduler_map_priority, T_scheduler_unmap_priority, \
265 T_scheduler_ask_for_help, T_scheduler_reconsider_help_request, \
266 T_scheduler_withdraw_node, T_scheduler_make_sticky, \
267 T_scheduler_clean_sticky, T_scheduler_pin, T_scheduler_unpin, \
268 T_scheduler_add_processor, T_scheduler_remove_processor, \
269 T_scheduler_node_initialize, T_scheduler_node_destroy, \
270 T_scheduler_release_job, T_scheduler_cancel_job, \
271 T_scheduler_start_idle, T_scheduler_set_affinity }
272#else
273#define T_SCHEDULER_ENTRY_POINTS { T_scheduler_initialize, \
274 T_scheduler_schedule, T_scheduler_yield, T_scheduler_block, \
275 T_scheduler_unblock, T_scheduler_update_priority, \
276 T_scheduler_map_priority, T_scheduler_unmap_priority, \
277 T_scheduler_node_initialize, T_scheduler_node_destroy, \
278 T_scheduler_release_job, T_scheduler_cancel_job, \
279 T_scheduler_start_idle }
280#endif
281
282extern const Scheduler_Operations T_scheduler_operations[];
283
286#ifdef __cplusplus
287}
288#endif
289
290#endif /* _RTEMS_TEST_SCHEDULER_H */
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:91
Status_Control
Status codes.
Definition: status.h:111
This header file provides the interfaces of the Processor Mask.
This header file provides interfaces of the Scheduler Handler which are used by the implementation an...
Per CPU Core Structure.
Definition: percpu.h:384
The priority node to build up a priority aggregation.
Definition: priority.h:112
Scheduler node for per-thread data.
Definition: schedulernode.h:94
The scheduler operations.
Definition: scheduler.h:62
Definition: test-scheduler.h:81
Definition: test-scheduler.h:127
Definition: test-scheduler.h:148
Definition: test-scheduler.h:153
Definition: test-scheduler.h:138
Definition: test-scheduler.h:158
Definition: test-scheduler.h:143
Definition: test-scheduler.h:133
Thread queue context for the thread queue methods.
Definition: threadq.h:216
Scheduler control.
Definition: scheduler.h:337
Definition: thread.h:837
This header file provides interfaces of the RTEMS Test Framework.