RTEMS: cpukit/include/rtems/score/scheduler.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
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
43typedef struct _Scheduler_Control Scheduler_Control;
44
48 typedef struct {
50 void ( *initialize )( const Scheduler_Control * );
51
53 void ( *schedule )( const Scheduler_Control *, Thread_Control *);
54
56 void ( *yield )(
57 const Scheduler_Control *,
58 Thread_Control *,
59 Scheduler_Node *
60 );
61
63 void ( *block )(
64 const Scheduler_Control *,
65 Thread_Control *,
66 Scheduler_Node *
67 );
68
70 void ( *unblock )(
71 const Scheduler_Control *,
72 Thread_Control *,
73 Scheduler_Node *
74 );
75
77 void ( *update_priority )(
78 const Scheduler_Control *,
79 Thread_Control *,
80 Scheduler_Node *
81 );
82
84 Priority_Control ( *map_priority )(
85 const Scheduler_Control *,
86 Priority_Control
87 );
88
90 Priority_Control ( *unmap_priority )(
91 const Scheduler_Control *,
92 Priority_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 *,
200 Scheduler_Node *,
201 Thread_Control *,
202 Priority_Control
203 );
204
206 void ( *node_destroy )( const Scheduler_Control *, Scheduler_Node * );
207
209 void ( *release_job ) (
210 const Scheduler_Control *,
211 Thread_Control *,
212 Priority_Node *,
213 uint64_t,
214 Thread_queue_Context *
215 );
216
218 void ( *cancel_job ) (
219 const Scheduler_Control *,
220 Thread_Control *,
221 Priority_Node *,
222 Thread_queue_Context *
223 );
224
226 void ( *tick )( const Scheduler_Control *, Thread_Control * );
227
229 void ( *start_idle )(
230 const Scheduler_Control *,
231 Thread_Control *,
232 struct Per_CPU_Control *
233 );
234
235#if defined(RTEMS_SMP)
237 bool ( *set_affinity )(
238 const Scheduler_Control *,
239 Thread_Control *,
240 Scheduler_Node *,
241 const Processor_mask *
242 );
243#endif
244} Scheduler_Operations;
245
252 typedef struct Scheduler_Context {
256 ISR_LOCK_MEMBER( Lock )
257
258#if defined(RTEMS_SMP)
262 Processor_mask Processors;
263#endif
264} Scheduler_Context;
265
269 struct _Scheduler_Control {
273 Scheduler_Context *context;
274
278 Scheduler_Operations Operations;
279
286 Priority_Control maximum_priority;
287
291 uint32_t name;
292
293#if defined(RTEMS_SMP)
298 bool is_non_preempt_mode_supported;
299#endif
300};
301
309extern const Scheduler_Control _Scheduler_Table[];
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
386 Priority_Control _Scheduler_default_Map_priority(
387 const Scheduler_Control *scheduler,
388 Priority_Control priority
389);
390
400 Priority_Control _Scheduler_default_Unmap_priority(
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
483void _Scheduler_default_Schedule(
484 const Scheduler_Control *scheduler,
485 Thread_Control *the_thread
486);
487
496void _Scheduler_default_Node_initialize(
497 const Scheduler_Control *scheduler,
498 Scheduler_Node *node,
499 Thread_Control *the_thread,
500 Priority_Control priority
501);
502
509void _Scheduler_default_Node_destroy(
510 const Scheduler_Control *scheduler,
511 Scheduler_Node *node
512);
513
525void _Scheduler_default_Release_job(
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
543void _Scheduler_default_Cancel_job(
544 const Scheduler_Control *scheduler,
545 Thread_Control *the_thread,
546 Priority_Node *priority_node,
547 Thread_queue_Context *queue_context
548);
549
559void _Scheduler_default_Tick(
560 const Scheduler_Control *scheduler,
561 Thread_Control *executing
562);
563
571void _Scheduler_default_Start_idle(
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 */
ISR_LOCK_MEMBER
#define ISR_LOCK_MEMBER(_designator)
Defines an ISR lock member.
Definition: isrlock.h:89
Priority_Control
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:70
_Scheduler_Count
#define _Scheduler_Count
Count of registered schedulers.
Definition: scheduler.h:325
_Scheduler_default_Tick
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
_Scheduler_default_Release_job
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
_Scheduler_default_Node_destroy
void _Scheduler_default_Node_destroy(const Scheduler_Control *scheduler, Scheduler_Node *node)
Does nothing.
Definition: schedulerdefaultnodedestroy.c:24
_Scheduler_Table
const Scheduler_Control _Scheduler_Table[]
Registered schedulers.
_Scheduler_default_Node_initialize
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
_Scheduler_default_Map_priority
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
_Scheduler_default_Schedule
void _Scheduler_default_Schedule(const Scheduler_Control *scheduler, Thread_Control *the_thread)
Does nothing.
Definition: schedulerdefaultschedule.c:15
_Scheduler_default_Unmap_priority
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
_Scheduler_default_Cancel_job
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
_Scheduler_default_Start_idle
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
thread.h
Constants and Structures Related with the Thread Control Block.
Per_CPU_Control
Per CPU Core Structure.
Definition: percpu.h:347
Priority_Node
The priority node to build up a priority aggregation.
Definition: priority.h:98
Scheduler_Context
Scheduler context.
Definition: scheduler.h:252
Scheduler_Node
Scheduler node for per-thread data.
Definition: schedulernode.h:79
Scheduler_Operations
The scheduler operations.
Definition: scheduler.h:48
Thread_queue_Context
Thread queue context for the thread queue methods.
Definition: threadq.h:198
_Scheduler_Control
Scheduler control.
Definition: scheduler.h:269
_Scheduler_Control::context
Scheduler_Context * context
Reference to a statically allocated scheduler context.
Definition: scheduler.h:273
_Scheduler_Control::name
uint32_t name
The scheduler name.
Definition: scheduler.h:291
_Scheduler_Control::Operations
Scheduler_Operations Operations
The scheduler operations.
Definition: scheduler.h:278
_Scheduler_Control::maximum_priority
Priority_Control maximum_priority
The maximum priority value of this scheduler.
Definition: scheduler.h:286
_Thread_Control
Definition: thread.h:732