RTEMS 6.1-rc7
Loading...
Searching...
No Matches
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#else
330 char empty;
331#endif
333
342
347
355
359 uint32_t name;
360
361#if defined(RTEMS_SMP)
366 bool is_non_preempt_mode_supported;
367#endif
368};
369
379
392#if defined(RTEMS_SMP)
393 extern const size_t _Scheduler_Count;
394#else
395 #define _Scheduler_Count ( (size_t) 1 )
396#endif
397
398#if defined(RTEMS_SMP)
402 #define SCHEDULER_ASSIGN_DEFAULT UINT32_C(0x0)
403
407 #define SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL SCHEDULER_ASSIGN_DEFAULT
408
412 #define SCHEDULER_ASSIGN_PROCESSOR_MANDATORY UINT32_C(0x1)
413
417 typedef struct {
421 const Scheduler_Control *scheduler;
422
432 uint32_t attributes;
433 } Scheduler_Assignment;
434
444 extern const Scheduler_Assignment _Scheduler_Initial_assignments[];
445#endif
446
457 const Scheduler_Control *scheduler,
458 Priority_Control priority
459);
460
471 const Scheduler_Control *scheduler,
472 Priority_Control priority
473);
474
475#if defined(RTEMS_SMP)
488 void _Scheduler_default_Sticky_do_nothing(
489 const Scheduler_Control *scheduler,
490 Thread_Control *the_thread,
491 Scheduler_Node *node
492 );
493
505 void _Scheduler_default_Pin_or_unpin_do_nothing(
506 const Scheduler_Control *scheduler,
507 Thread_Control *the_thread,
508 Scheduler_Node *node,
509 struct Per_CPU_Control *cpu
510 );
511
524 void _Scheduler_default_Pin_or_unpin_not_supported(
525 const Scheduler_Control *scheduler,
526 Thread_Control *the_thread,
527 Scheduler_Node *node,
528 struct Per_CPU_Control *cpu
529 );
530#endif
531
551#if defined(RTEMS_SMP)
552 #define SCHEDULER_DEFAULT_SMP_OPERATIONS \
553 NULL, \
554 NULL, \
555 NULL, \
556 _Scheduler_default_Sticky_do_nothing, \
557 _Scheduler_default_Sticky_do_nothing, \
558 _Scheduler_default_Pin_or_unpin_do_nothing, \
559 _Scheduler_default_Pin_or_unpin_do_nothing, \
560 NULL, \
561 NULL,
562#else
563 #define SCHEDULER_DEFAULT_SMP_OPERATIONS
564#endif
565
573 const Scheduler_Control *scheduler,
574 Thread_Control *the_thread
575);
576
586 const Scheduler_Control *scheduler,
587 Scheduler_Node *node,
588 Thread_Control *the_thread,
589 Priority_Control priority
590);
591
599 const Scheduler_Control *scheduler,
600 Scheduler_Node *node
601);
602
615 const Scheduler_Control *scheduler,
616 Thread_Control *the_thread,
617 Priority_Node *priority_node,
618 uint64_t deadline,
619 Thread_queue_Context *queue_context
620);
621
633 const Scheduler_Control *scheduler,
634 Thread_Control *the_thread,
635 Priority_Node *priority_node,
636 Thread_queue_Context *queue_context
637);
638
647 const Scheduler_Control *scheduler,
648 Thread_Control *the_thread,
649 struct Per_CPU_Control *cpu
650);
651
652#if defined(RTEMS_SMP)
669 Status_Control _Scheduler_default_Set_affinity(
670 const Scheduler_Control *scheduler,
671 Thread_Control *thread,
672 Scheduler_Node *node,
673 const Processor_mask *affinity
674 );
675#endif
676
687#if defined(RTEMS_SMP)
688 #define SCHEDULER_DEFAULT_SET_AFFINITY_OPERATION \
689 , _Scheduler_default_Set_affinity
690#else
691 #define SCHEDULER_DEFAULT_SET_AFFINITY_OPERATION
692#endif
693
698#define PRIORITY_MAXIMUM ( _Scheduler_Table[ 0 ].maximum_priority )
699
702#ifdef __cplusplus
703}
704#endif
705
706#endif
707/* end of include file */
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:91
#define _Scheduler_Count
This constant contains the count of configured schedulers.
Definition: scheduler.h:395
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...
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:337
Scheduler_Context * context
Reference to a statically allocated scheduler context.
Definition: scheduler.h:341
uint32_t name
The scheduler name.
Definition: scheduler.h:359
Scheduler_Operations Operations
The scheduler operations.
Definition: scheduler.h:346
Priority_Control maximum_priority
The maximum priority value of this scheduler.
Definition: scheduler.h:354
Definition: thread.h:837