RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
scheduler.h
Go to the documentation of this file.
1
12/*
13 * Copyright (C) 2010 Gedare Bloom.
14 * Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
15 *
16 * The license and distribution terms for this file may be
17 * found in the file LICENSE in this distribution or at
18 * http://www.rtems.org/license/LICENSE.
19 */
20
21#ifndef _RTEMS_SCORE_SCHEDULER_H
22#define _RTEMS_SCORE_SCHEDULER_H
23
24#include <rtems/score/thread.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30struct Per_CPU_Control;
31
44
48typedef struct {
50 void ( *initialize )( const Scheduler_Control * );
51
53 void ( *schedule )( const Scheduler_Control *, Thread_Control *);
54
56 void ( *yield )(
57 const Scheduler_Control *,
60 );
61
63 void ( *block )(
64 const Scheduler_Control *,
67 );
68
70 void ( *unblock )(
71 const Scheduler_Control *,
74 );
75
77 void ( *update_priority )(
78 const Scheduler_Control *,
81 );
82
84 Priority_Control ( *map_priority )(
85 const Scheduler_Control *,
87 );
88
90 Priority_Control ( *unmap_priority )(
91 const Scheduler_Control *,
93 );
94
95#if defined(RTEMS_SMP)
106 bool ( *ask_for_help )(
107 const Scheduler_Control *scheduler,
108 Thread_Control *the_thread,
109 Scheduler_Node *node
110 );
111
120 void ( *reconsider_help_request )(
121 const Scheduler_Control *scheduler,
122 Thread_Control *the_thread,
123 Scheduler_Node *node
124 );
125
135 void ( *withdraw_node )(
136 const Scheduler_Control *scheduler,
137 Thread_Control *the_thread,
138 Scheduler_Node *node,
139 Thread_Scheduler_state next_state
140 );
141
150 void ( *pin )(
151 const Scheduler_Control *scheduler,
152 Thread_Control *the_thread,
153 Scheduler_Node *node,
154 struct Per_CPU_Control *cpu
155 );
156
165 void ( *unpin )(
166 const Scheduler_Control *scheduler,
167 Thread_Control *the_thread,
168 Scheduler_Node *node,
169 struct Per_CPU_Control *cpu
170 );
171
178 void ( *add_processor )(
179 const Scheduler_Control *scheduler,
180 Thread_Control *idle
181 );
182
191 Thread_Control *( *remove_processor )(
192 const Scheduler_Control *scheduler,
193 struct Per_CPU_Control *cpu
194 );
195#endif
196
198 void ( *node_initialize )(
199 const Scheduler_Control *,
203 );
204
206 void ( *node_destroy )( const Scheduler_Control *, Scheduler_Node * );
207
209 void ( *release_job ) (
210 const Scheduler_Control *,
213 uint64_t,
215 );
216
218 void ( *cancel_job ) (
219 const Scheduler_Control *,
223 );
224
226 void ( *tick )( const Scheduler_Control *, Thread_Control * );
227
229 void ( *start_idle )(
230 const Scheduler_Control *,
232 struct Per_CPU_Control *
233 );
234
235#if defined(RTEMS_SMP)
237 bool ( *set_affinity )(
238 const Scheduler_Control *,
241 const Processor_mask *
242 );
243#endif
245
252typedef struct Scheduler_Context {
256 ISR_LOCK_MEMBER( Lock )
257
258#if defined(RTEMS_SMP)
262 Processor_mask Processors;
263#endif
265
274
279
287
291 uint32_t name;
292
293#if defined(RTEMS_SMP)
298 bool is_non_preempt_mode_supported;
299#endif
300};
301
310
322#if defined(RTEMS_SMP)
323 extern const size_t _Scheduler_Count;
324#else
325 #define _Scheduler_Count ( (size_t) 1 )
326#endif
327
328#if defined(RTEMS_SMP)
332 #define SCHEDULER_ASSIGN_DEFAULT UINT32_C(0x0)
333
337 #define SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL SCHEDULER_ASSIGN_DEFAULT
338
342 #define SCHEDULER_ASSIGN_PROCESSOR_MANDATORY UINT32_C(0x1)
343
347 typedef struct {
351 const Scheduler_Control *scheduler;
352
362 uint32_t attributes;
363 } Scheduler_Assignment;
364
374 extern const Scheduler_Assignment _Scheduler_Initial_assignments[];
375#endif
376
387 const Scheduler_Control *scheduler,
388 Priority_Control priority
389);
390
401 const Scheduler_Control *scheduler,
402 Priority_Control priority
403);
404
405#if defined(RTEMS_SMP)
415 bool _Scheduler_default_Ask_for_help(
416 const Scheduler_Control *scheduler,
417 Thread_Control *the_thread,
418 Scheduler_Node *node
419 );
420
428 void _Scheduler_default_Reconsider_help_request(
429 const Scheduler_Control *scheduler,
430 Thread_Control *the_thread,
431 Scheduler_Node *node
432 );
433
442 void _Scheduler_default_Withdraw_node(
443 const Scheduler_Control *scheduler,
444 Thread_Control *the_thread,
445 Scheduler_Node *node,
446 Thread_Scheduler_state next_state
447 );
448
458 void _Scheduler_default_Pin_or_unpin(
459 const Scheduler_Control *scheduler,
460 Thread_Control *the_thread,
461 Scheduler_Node *node,
462 struct Per_CPU_Control *cpu
463 );
464
465 #define SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \
466 _Scheduler_default_Ask_for_help, \
467 _Scheduler_default_Reconsider_help_request, \
468 _Scheduler_default_Withdraw_node, \
469 _Scheduler_default_Pin_or_unpin, \
470 _Scheduler_default_Pin_or_unpin, \
471 NULL, \
472 NULL,
473#else
474 #define SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP
475#endif
476
484 const Scheduler_Control *scheduler,
485 Thread_Control *the_thread
486);
487
497 const Scheduler_Control *scheduler,
498 Scheduler_Node *node,
499 Thread_Control *the_thread,
500 Priority_Control priority
501);
502
510 const Scheduler_Control *scheduler,
511 Scheduler_Node *node
512);
513
526 const Scheduler_Control *scheduler,
527 Thread_Control *the_thread,
528 Priority_Node *priority_node,
529 uint64_t deadline,
530 Thread_queue_Context *queue_context
531);
532
544 const Scheduler_Control *scheduler,
545 Thread_Control *the_thread,
546 Priority_Node *priority_node,
547 Thread_queue_Context *queue_context
548);
549
560 const Scheduler_Control *scheduler,
561 Thread_Control *executing
562);
563
572 const Scheduler_Control *scheduler,
573 Thread_Control *the_thread,
574 struct Per_CPU_Control *cpu
575);
576
577#if defined(RTEMS_SMP)
591 bool _Scheduler_default_Set_affinity(
592 const Scheduler_Control *scheduler,
593 Thread_Control *thread,
594 Scheduler_Node *node,
595 const Processor_mask *affinity
596 );
597
598 #define SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \
599 , _Scheduler_default_Set_affinity
600#else
601 #define SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY
602#endif
603
608#define PRIORITY_MAXIMUM ( _Scheduler_Table[ 0 ].maximum_priority )
609
612#ifdef __cplusplus
613}
614#endif
615
616#endif
617/* end of include file */
#define ISR_LOCK_MEMBER(_designator)
Defines an ISR lock member.
Definition: isrlock.h:89
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:70
struct Scheduler_Context Scheduler_Context
Scheduler context.
#define _Scheduler_Count
Count of registered schedulers.
Definition: scheduler.h:325
void _Scheduler_default_Tick(const Scheduler_Control *scheduler, Thread_Control *executing)
Performs tick operations depending on the CPU budget algorithm for each executing thread.
Definition: schedulerdefaulttick.c:27
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:24
void _Scheduler_default_Node_destroy(const Scheduler_Control *scheduler, Scheduler_Node *node)
Does nothing.
Definition: schedulerdefaultnodedestroy.c:24
const Scheduler_Control _Scheduler_Table[]
Registered 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:24
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:15
void _Scheduler_default_Schedule(const Scheduler_Control *scheduler, Thread_Control *the_thread)
Does nothing.
Definition: schedulerdefaultschedule.c:15
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:23
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:39
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:15
Constants and Structures Related with the Thread Control Block.
Per CPU Core Structure.
Definition: percpu.h:347
The priority node to build up a priority aggregation.
Definition: priority.h:98
Scheduler context.
Definition: scheduler.h:252
Scheduler node for per-thread data.
Definition: schedulernode.h:79
The scheduler operations.
Definition: scheduler.h:48
Thread queue context for the thread queue methods.
Definition: threadq.h:198
Scheduler control.
Definition: scheduler.h:269
Scheduler_Context * context
Reference to a statically allocated scheduler context.
Definition: scheduler.h:273
uint32_t name
The scheduler name.
Definition: scheduler.h:291
Scheduler_Operations Operations
The scheduler operations.
Definition: scheduler.h:278
Priority_Control maximum_priority
The maximum priority value of this scheduler.
Definition: scheduler.h:286
Definition: thread.h:732