RTEMS
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
27 extern "C" {
28 #endif
29 
30 struct Per_CPU_Control;
31 
39 
43 typedef struct {
45  void ( *initialize )( const Scheduler_Control * );
46 
48  void ( *schedule )( const Scheduler_Control *, Thread_Control *);
49 
51  void ( *yield )(
52  const Scheduler_Control *,
55  );
56 
58  void ( *block )(
59  const Scheduler_Control *,
62  );
63 
65  void ( *unblock )(
66  const Scheduler_Control *,
69  );
70 
72  void ( *update_priority )(
73  const Scheduler_Control *,
76  );
77 
79  Priority_Control ( *map_priority )(
80  const Scheduler_Control *,
82  );
83 
85  Priority_Control ( *unmap_priority )(
86  const Scheduler_Control *,
88  );
89 
90 #if defined(RTEMS_SMP)
91 
101  bool ( *ask_for_help )(
102  const Scheduler_Control *scheduler,
103  Thread_Control *the_thread,
104  Scheduler_Node *node
105  );
106 
115  void ( *reconsider_help_request )(
116  const Scheduler_Control *scheduler,
117  Thread_Control *the_thread,
118  Scheduler_Node *node
119  );
120 
130  void ( *withdraw_node )(
131  const Scheduler_Control *scheduler,
132  Thread_Control *the_thread,
133  Scheduler_Node *node,
134  Thread_Scheduler_state next_state
135  );
136 
145  void ( *pin )(
146  const Scheduler_Control *scheduler,
147  Thread_Control *the_thread,
148  Scheduler_Node *node,
149  struct Per_CPU_Control *cpu
150  );
151 
160  void ( *unpin )(
161  const Scheduler_Control *scheduler,
162  Thread_Control *the_thread,
163  Scheduler_Node *node,
164  struct Per_CPU_Control *cpu
165  );
166 
173  void ( *add_processor )(
174  const Scheduler_Control *scheduler,
175  Thread_Control *idle
176  );
177 
186  Thread_Control *( *remove_processor )(
187  const Scheduler_Control *scheduler,
188  struct Per_CPU_Control *cpu
189  );
190 #endif
191 
193  void ( *node_initialize )(
194  const Scheduler_Control *,
195  Scheduler_Node *,
196  Thread_Control *,
198  );
199 
201  void ( *node_destroy )( const Scheduler_Control *, Scheduler_Node * );
202 
204  void ( *release_job ) (
205  const Scheduler_Control *,
206  Thread_Control *,
207  Priority_Node *,
208  uint64_t,
210  );
211 
213  void ( *cancel_job ) (
214  const Scheduler_Control *,
215  Thread_Control *,
216  Priority_Node *,
218  );
219 
221  void ( *tick )( const Scheduler_Control *, Thread_Control * );
222 
224  void ( *start_idle )(
225  const Scheduler_Control *,
226  Thread_Control *,
227  struct Per_CPU_Control *
228  );
229 
230 #if defined(RTEMS_SMP)
231 
232  bool ( *set_affinity )(
233  const Scheduler_Control *,
234  Thread_Control *,
235  Scheduler_Node *,
236  const Processor_mask *
237  );
238 #endif
240 
247 typedef struct Scheduler_Context {
251  ISR_LOCK_MEMBER( Lock )
252 
253 #if defined(RTEMS_SMP)
254 
257  Processor_mask Processors;
258 #endif
260 
269 
274 
282 
286  uint32_t name;
287 
288 #if defined(RTEMS_SMP)
289 
294 #endif
295 };
296 
305 extern const Scheduler_Control _Scheduler_Table[];
306 
319 #if defined(RTEMS_SMP)
320  extern const size_t _Scheduler_Count;
321 #else
322  #define _Scheduler_Count ( (size_t) 1 )
323 #endif
324 
325 #if defined(RTEMS_SMP)
326 
329  #define SCHEDULER_ASSIGN_DEFAULT UINT32_C(0x0)
330 
334  #define SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL SCHEDULER_ASSIGN_DEFAULT
335 
339  #define SCHEDULER_ASSIGN_PROCESSOR_MANDATORY UINT32_C(0x1)
340 
344  typedef struct {
349 
359  uint32_t attributes;
361 
372 #endif
373 
384  const Scheduler_Control *scheduler,
385  Priority_Control priority
386 );
387 
398  const Scheduler_Control *scheduler,
399  Priority_Control priority
400 );
401 
402 #if defined(RTEMS_SMP)
403 
413  const Scheduler_Control *scheduler,
414  Thread_Control *the_thread,
415  Scheduler_Node *node
416  );
417 
426  const Scheduler_Control *scheduler,
427  Thread_Control *the_thread,
428  Scheduler_Node *node
429  );
430 
440  const Scheduler_Control *scheduler,
441  Thread_Control *the_thread,
442  Scheduler_Node *node,
443  Thread_Scheduler_state next_state
444  );
445 
456  const Scheduler_Control *scheduler,
457  Thread_Control *the_thread,
458  Scheduler_Node *node,
459  struct Per_CPU_Control *cpu
460  );
461 
462  #define SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \
463  _Scheduler_default_Ask_for_help, \
464  _Scheduler_default_Reconsider_help_request, \
465  _Scheduler_default_Withdraw_node, \
466  _Scheduler_default_Pin_or_unpin, \
467  _Scheduler_default_Pin_or_unpin, \
468  NULL, \
469  NULL,
470 #else
471  #define SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP
472 #endif
473 
481  const Scheduler_Control *scheduler,
482  Thread_Control *the_thread
483 );
484 
494  const Scheduler_Control *scheduler,
495  Scheduler_Node *node,
496  Thread_Control *the_thread,
497  Priority_Control priority
498 );
499 
507  const Scheduler_Control *scheduler,
508  Scheduler_Node *node
509 );
510 
523  const Scheduler_Control *scheduler,
524  Thread_Control *the_thread,
525  Priority_Node *priority_node,
526  uint64_t deadline,
527  Thread_queue_Context *queue_context
528 );
529 
541  const Scheduler_Control *scheduler,
542  Thread_Control *the_thread,
543  Priority_Node *priority_node,
544  Thread_queue_Context *queue_context
545 );
546 
557  const Scheduler_Control *scheduler,
558  Thread_Control *executing
559 );
560 
569  const Scheduler_Control *scheduler,
570  Thread_Control *the_thread,
571  struct Per_CPU_Control *cpu
572 );
573 
574 #if defined(RTEMS_SMP)
575 
589  const Scheduler_Control *scheduler,
590  Thread_Control *thread,
591  Scheduler_Node *node,
592  const Processor_mask *affinity
593  );
594 
595  #define SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \
596  , _Scheduler_default_Set_affinity
597 #else
598  #define SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY
599 #endif
600 
605 #define PRIORITY_MAXIMUM ( _Scheduler_Table[ 0 ].maximum_priority )
606 
609 #ifdef __cplusplus
610 }
611 #endif
612 
613 #endif
614 /* end of include file */
void _Scheduler_default_Withdraw_node(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node, Thread_Scheduler_state next_state)
Does nothing.
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:70
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.
Scheduler context.
Definition: scheduler.h:247
The scheduler operations.
Definition: scheduler.h:43
Thread queue context for the thread queue methods.
Definition: threadq.h:198
The priority node to build up a priority aggregation.
Definition: priority.h:98
Priority_Control _Scheduler_default_Map_priority(const Scheduler_Control *scheduler, Priority_Control priority)
Returns the scheduler internal thread priority mapped by SCHEDULER_PRIORITY_MAP().
bool _Scheduler_default_Ask_for_help(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node)
Does nothing.
uint32_t name
The scheduler name.
Definition: scheduler.h:286
bool is_non_preempt_mode_supported
True if the non-preempt mode for threads is supported by the scheduler, otherwise false...
Definition: scheduler.h:293
void _Scheduler_default_Schedule(const Scheduler_Control *scheduler, Thread_Control *the_thread)
Does nothing.
bool _Scheduler_default_Set_affinity(const Scheduler_Control *scheduler, Thread_Control *thread, Scheduler_Node *node, const Processor_mask *affinity)
Checks if the processor set of the scheduler is the subset of the affinity set.
struct Scheduler_Context Scheduler_Context
Scheduler context.
const Scheduler_Assignment _Scheduler_Initial_assignments[]
The scheduler assignments.
uint32_t attributes
The scheduler assignment attributes.
Definition: scheduler.h:359
Scheduler assignment.
Definition: scheduler.h:344
#define ISR_LOCK_MEMBER(_designator)
Defines an ISR lock member.
Definition: isrlock.h:87
Thread_Scheduler_state
The thread state with respect to the scheduler.
Definition: thread.h:214
Per CPU Core Structure.
Definition: percpu.h:347
void _Scheduler_default_Node_destroy(const Scheduler_Control *scheduler, Scheduler_Node *node)
Does nothing.
Priority_Control maximum_priority
The maximum priority value of this scheduler.
Definition: scheduler.h:281
Processor_mask Processors
Lock to protect this scheduler instance.
Definition: scheduler.h:257
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.
void _Scheduler_default_Pin_or_unpin(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node, struct Per_CPU_Control *cpu)
Does nothing in a single processor system, otherwise a fatal error is issued.
const Scheduler_Control * scheduler
The scheduler for this processor.
Definition: scheduler.h:348
Scheduler_Operations Operations
The scheduler operations.
Definition: scheduler.h:273
const size_t _Scheduler_Count
This constant contains the count of configured schedulers.
Scheduler control.
Definition: scheduler.h:264
Scheduler node for per-thread data.
Definition: schedulernode.h:79
void _Scheduler_default_Tick(const Scheduler_Control *scheduler, Thread_Control *executing)
Performs tick operations depending on the CPU budget algorithm for each executing thread...
void _Scheduler_default_Cancel_job(const Scheduler_Control *scheduler, Thread_Control *the_thread, Priority_Node *priority_node, Thread_queue_Context *queue_context)
Does nothing.
void _Scheduler_default_Reconsider_help_request(const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node)
Does nothing.
Scheduler_Context * context
Reference to a statically allocated scheduler context.
Definition: scheduler.h:268
Priority_Control _Scheduler_default_Unmap_priority(const Scheduler_Control *scheduler, Priority_Control priority)
Returns the user visible thread priority unmapped by SCHEDULER_PRIORITY_UNMAP().
void _Scheduler_default_Start_idle(const Scheduler_Control *scheduler, Thread_Control *the_thread, struct Per_CPU_Control *cpu)
Starts an idle thread.
Constants and Structures Related with the Thread Control Block.