RTEMS 6.1-rc1
scheduler.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
13/*
14 * Copyright (C) 2010 Gedare Bloom.
15 * Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#ifndef _RTEMS_SCORE_SCHEDULER_H
40#define _RTEMS_SCORE_SCHEDULER_H
41
42#include <rtems/score/thread.h>
43#include <rtems/score/status.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49struct Per_CPU_Control;
50
58
62typedef struct {
64 void ( *initialize )( const Scheduler_Control * );
65
67 void ( *schedule )( const Scheduler_Control *, Thread_Control *);
68
70 void ( *yield )(
71 const Scheduler_Control *,
74 );
75
77 void ( *block )(
78 const Scheduler_Control *,
81 );
82
84 void ( *unblock )(
85 const Scheduler_Control *,
88 );
89
91 void ( *update_priority )(
92 const Scheduler_Control *,
95 );
96
98 Priority_Control ( *map_priority )(
99 const Scheduler_Control *,
101 );
102
104 Priority_Control ( *unmap_priority )(
105 const Scheduler_Control *,
107 );
108
109#if defined(RTEMS_SMP)
120 bool ( *ask_for_help )(
121 const Scheduler_Control *scheduler,
122 Thread_Control *the_thread,
123 Scheduler_Node *node
124 );
125
134 void ( *reconsider_help_request )(
135 const Scheduler_Control *scheduler,
136 Thread_Control *the_thread,
137 Scheduler_Node *node
138 );
139
149 void ( *withdraw_node )(
150 const Scheduler_Control *scheduler,
151 Thread_Control *the_thread,
152 Scheduler_Node *node,
153 Thread_Scheduler_state next_state
154 );
155
181 void ( *make_sticky )(
182 const Scheduler_Control *scheduler,
183 Thread_Control *the_thread,
184 Scheduler_Node *node
185 );
186
205 void ( *clean_sticky )(
206 const Scheduler_Control *scheduler,
207 Thread_Control *the_thread,
208 Scheduler_Node *node
209 );
210
219 void ( *pin )(
220 const Scheduler_Control *scheduler,
221 Thread_Control *the_thread,
222 Scheduler_Node *node,
223 struct Per_CPU_Control *cpu
224 );
225
234 void ( *unpin )(
235 const Scheduler_Control *scheduler,
236 Thread_Control *the_thread,
237 Scheduler_Node *node,
238 struct Per_CPU_Control *cpu
239 );
240
247 void ( *add_processor )(
248 const Scheduler_Control *scheduler,
249 Thread_Control *idle
250 );
251
260 Thread_Control *( *remove_processor )(
261 const Scheduler_Control *scheduler,
262 struct Per_CPU_Control *cpu
263 );
264#endif
265
267 void ( *node_initialize )(
268 const Scheduler_Control *,
272 );
273
275 void ( *node_destroy )( const Scheduler_Control *, Scheduler_Node * );
276
278 void ( *release_job ) (
279 const Scheduler_Control *,
282 uint64_t,
284 );
285
287 void ( *cancel_job ) (
288 const Scheduler_Control *,
292 );
293
295 void ( *start_idle )(
296 const Scheduler_Control *,
298 struct Per_CPU_Control *
299 );
300
301#if defined(RTEMS_SMP)
303 Status_Control ( *set_affinity )(
304 const Scheduler_Control *,
307 const Processor_mask *
308 );
309#endif
311
318typedef struct Scheduler_Context {
319#if defined(RTEMS_SMP)
323 ISR_lock_Control Lock;
324
328 Processor_mask Processors;
329#endif
331
340
345
353
357 uint32_t name;
358
359#if defined(RTEMS_SMP)
364 bool is_non_preempt_mode_supported;
365#endif
366};
367
377
390#if defined(RTEMS_SMP)
391 extern const size_t _Scheduler_Count;
392#else
393 #define _Scheduler_Count ( (size_t) 1 )
394#endif
395
396#if defined(RTEMS_SMP)
400 #define SCHEDULER_ASSIGN_DEFAULT UINT32_C(0x0)
401
405 #define SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL SCHEDULER_ASSIGN_DEFAULT
406
410 #define SCHEDULER_ASSIGN_PROCESSOR_MANDATORY UINT32_C(0x1)
411
415 typedef struct {
419 const Scheduler_Control *scheduler;
420
430 uint32_t attributes;
431 } Scheduler_Assignment;
432
442 extern const Scheduler_Assignment _Scheduler_Initial_assignments[];
443#endif
444
455 const Scheduler_Control *scheduler,
456 Priority_Control priority
457);
458
469 const Scheduler_Control *scheduler,
470 Priority_Control priority
471);
472
473#if defined(RTEMS_SMP)
486 void _Scheduler_default_Sticky_do_nothing(
487 const Scheduler_Control *scheduler,
488 Thread_Control *the_thread,
489 Scheduler_Node *node
490 );
491
503 void _Scheduler_default_Pin_or_unpin_do_nothing(
504 const Scheduler_Control *scheduler,
505 Thread_Control *the_thread,
506 Scheduler_Node *node,
507 struct Per_CPU_Control *cpu
508 );
509
522 void _Scheduler_default_Pin_or_unpin_not_supported(
523 const Scheduler_Control *scheduler,
524 Thread_Control *the_thread,
525 Scheduler_Node *node,
526 struct Per_CPU_Control *cpu
527 );
528#endif
529
549#if defined(RTEMS_SMP)
550 #define SCHEDULER_DEFAULT_SMP_OPERATIONS \
551 NULL, \
552 NULL, \
553 NULL, \
554 _Scheduler_default_Sticky_do_nothing, \
555 _Scheduler_default_Sticky_do_nothing, \
556 _Scheduler_default_Pin_or_unpin_do_nothing, \
557 _Scheduler_default_Pin_or_unpin_do_nothing, \
558 NULL, \
559 NULL,
560#else
561 #define SCHEDULER_DEFAULT_SMP_OPERATIONS
562#endif
563
571 const Scheduler_Control *scheduler,
572 Thread_Control *the_thread
573);
574
584 const Scheduler_Control *scheduler,
585 Scheduler_Node *node,
586 Thread_Control *the_thread,
587 Priority_Control priority
588);
589
597 const Scheduler_Control *scheduler,
598 Scheduler_Node *node
599);
600
613 const Scheduler_Control *scheduler,
614 Thread_Control *the_thread,
615 Priority_Node *priority_node,
616 uint64_t deadline,
617 Thread_queue_Context *queue_context
618);
619
631 const Scheduler_Control *scheduler,
632 Thread_Control *the_thread,
633 Priority_Node *priority_node,
634 Thread_queue_Context *queue_context
635);
636
645 const Scheduler_Control *scheduler,
646 Thread_Control *the_thread,
647 struct Per_CPU_Control *cpu
648);
649
650#if defined(RTEMS_SMP)
667 Status_Control _Scheduler_default_Set_affinity(
668 const Scheduler_Control *scheduler,
669 Thread_Control *thread,
670 Scheduler_Node *node,
671 const Processor_mask *affinity
672 );
673#endif
674
685#if defined(RTEMS_SMP)
686 #define SCHEDULER_DEFAULT_SET_AFFINITY_OPERATION \
687 , _Scheduler_default_Set_affinity
688#else
689 #define SCHEDULER_DEFAULT_SET_AFFINITY_OPERATION
690#endif
691
696#define PRIORITY_MAXIMUM ( _Scheduler_Table[ 0 ].maximum_priority )
697
700#ifdef __cplusplus
701}
702#endif
703
704#endif
705/* end of include file */
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:91
struct Scheduler_Context Scheduler_Context
Scheduler context.
#define _Scheduler_Count
This constant contains the count of configured schedulers.
Definition: scheduler.h:393
void _Scheduler_default_Release_job(const Scheduler_Control *scheduler, Thread_Control *the_thread, Priority_Node *priority_node, uint64_t deadline, Thread_queue_Context *queue_context)
Does nothing.
Definition: schedulerdefaultreleasejob.c:44
void _Scheduler_default_Node_destroy(const Scheduler_Control *scheduler, Scheduler_Node *node)
Does nothing.
Definition: schedulerdefaultnodedestroy.c:45
const Scheduler_Control _Scheduler_Table[]
This table contains the configured schedulers.
void _Scheduler_default_Node_initialize(const Scheduler_Control *scheduler, Scheduler_Node *node, Thread_Control *the_thread, Priority_Control priority)
Performs the scheduler base node initialization.
Definition: schedulerdefaultnodeinit.c:44
Priority_Control _Scheduler_default_Map_priority(const Scheduler_Control *scheduler, Priority_Control priority)
Returns the scheduler internal thread priority mapped by SCHEDULER_PRIORITY_MAP().
Definition: schedulerdefaultmappriority.c:43
void _Scheduler_default_Schedule(const Scheduler_Control *scheduler, Thread_Control *the_thread)
Does nothing.
Definition: schedulerdefaultschedule.c:43
Priority_Control _Scheduler_default_Unmap_priority(const Scheduler_Control *scheduler, Priority_Control priority)
Returns the user visible thread priority unmapped by SCHEDULER_PRIORITY_UNMAP().
Definition: schedulerdefaultmappriority.c:51
void _Scheduler_default_Cancel_job(const Scheduler_Control *scheduler, Thread_Control *the_thread, Priority_Node *priority_node, Thread_queue_Context *queue_context)
Does nothing.
Definition: schedulerdefaultreleasejob.c:59
void _Scheduler_default_Start_idle(const Scheduler_Control *scheduler, Thread_Control *the_thread, struct Per_CPU_Control *cpu)
Starts an idle thread.
Definition: schedulerdefaultstartidle.c:43
Status_Control
Status codes.
Definition: status.h:111
This header file provides the interfaces of the Operation Status Support.
This header file provides interfaces of the Thread Handler which are used by the implementation and t...
ISR lock control.
Definition: isrlock.h:72
Per CPU Core Structure.
Definition: percpu.h:384
The priority node to build up a priority aggregation.
Definition: priority.h:112
Scheduler context.
Definition: scheduler.h:318
Scheduler node for per-thread data.
Definition: schedulernode.h:94
The scheduler operations.
Definition: scheduler.h:62
Thread queue context for the thread queue methods.
Definition: threadq.h:216
Scheduler control.
Definition: scheduler.h:335
Scheduler_Context * context
Reference to a statically allocated scheduler context.
Definition: scheduler.h:339
uint32_t name
The scheduler name.
Definition: scheduler.h:357
Scheduler_Operations Operations
The scheduler operations.
Definition: scheduler.h:344
Priority_Control maximum_priority
The maximum priority value of this scheduler.
Definition: scheduler.h:352
Definition: thread.h:812