1 | /** |
---|
2 | * @file rtems/score/schedulersimple.h |
---|
3 | * |
---|
4 | * @brief Manipulation of Threads Simple-Priority-Based Ready Queue |
---|
5 | * |
---|
6 | * This include file contains all the constants and structures associated |
---|
7 | * with the manipulation of threads on a simple-priority-based ready queue. |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.org/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef _RTEMS_SCORE_SCHEDULERSIMPLE_H |
---|
19 | #define _RTEMS_SCORE_SCHEDULERSIMPLE_H |
---|
20 | |
---|
21 | #include <rtems/score/scheduler.h> |
---|
22 | #include <rtems/score/schedulerpriority.h> |
---|
23 | |
---|
24 | #ifdef __cplusplus |
---|
25 | extern "C" { |
---|
26 | #endif |
---|
27 | |
---|
28 | /** |
---|
29 | * @defgroup ScoreSchedulerSimple Simple Priority Scheduler |
---|
30 | * |
---|
31 | * @ingroup ScoreScheduler |
---|
32 | */ |
---|
33 | /**@{*/ |
---|
34 | |
---|
35 | #define SCHEDULER_SIMPLE_MAXIMUM_PRIORITY 255 |
---|
36 | |
---|
37 | /** |
---|
38 | * Entry points for Scheduler Simple |
---|
39 | */ |
---|
40 | #define SCHEDULER_SIMPLE_ENTRY_POINTS \ |
---|
41 | { \ |
---|
42 | _Scheduler_simple_Initialize, /* initialize entry point */ \ |
---|
43 | _Scheduler_simple_Schedule, /* schedule entry point */ \ |
---|
44 | _Scheduler_simple_Yield, /* yield entry point */ \ |
---|
45 | _Scheduler_simple_Block, /* block entry point */ \ |
---|
46 | _Scheduler_simple_Unblock, /* unblock entry point */ \ |
---|
47 | _Scheduler_simple_Update_priority, /* update priority entry point */ \ |
---|
48 | _Scheduler_default_Map_priority, /* map priority entry point */ \ |
---|
49 | _Scheduler_default_Unmap_priority, /* unmap priority entry point */ \ |
---|
50 | SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \ |
---|
51 | _Scheduler_default_Node_initialize, /* node initialize entry point */ \ |
---|
52 | _Scheduler_default_Node_destroy, /* node destroy entry point */ \ |
---|
53 | _Scheduler_default_Release_job, /* new period of task */ \ |
---|
54 | _Scheduler_default_Tick, /* tick entry point */ \ |
---|
55 | _Scheduler_default_Start_idle /* start idle entry point */ \ |
---|
56 | SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ |
---|
57 | } |
---|
58 | |
---|
59 | /** |
---|
60 | * @brief Simple scheduler context. |
---|
61 | */ |
---|
62 | typedef struct { |
---|
63 | /** |
---|
64 | * @brief Basic scheduler context. |
---|
65 | */ |
---|
66 | Scheduler_Context Base; |
---|
67 | |
---|
68 | /** |
---|
69 | * @brief One ready queue for all ready threads. |
---|
70 | */ |
---|
71 | Chain_Control Ready; |
---|
72 | } Scheduler_simple_Context; |
---|
73 | |
---|
74 | /** |
---|
75 | * @brief Initialize simple scheduler. |
---|
76 | * |
---|
77 | * This routine initializes the simple scheduler. |
---|
78 | */ |
---|
79 | void _Scheduler_simple_Initialize( const Scheduler_Control *scheduler ); |
---|
80 | |
---|
81 | /** |
---|
82 | * This routine sets the heir thread to be the next ready thread |
---|
83 | * on the ready queue by getting the first node in the scheduler |
---|
84 | * information. |
---|
85 | * |
---|
86 | * @param[in] scheduler The scheduler instance. |
---|
87 | * @param[in] the_thread causing the scheduling operation. |
---|
88 | */ |
---|
89 | void _Scheduler_simple_Schedule( |
---|
90 | const Scheduler_Control *scheduler, |
---|
91 | Thread_Control *the_thread |
---|
92 | ); |
---|
93 | |
---|
94 | /** |
---|
95 | * @brief Invoked when a thread wishes to voluntarily |
---|
96 | * transfer control of the processor to another thread in the queue. |
---|
97 | * |
---|
98 | * This routine is invoked when a thread wishes to voluntarily |
---|
99 | * transfer control of the processor to another thread in the queue. |
---|
100 | * It will remove the specified THREAD from the scheduler.informaiton |
---|
101 | * (where the ready queue is stored) and place it immediately at the |
---|
102 | * between the last entry of its priority and the next priority thread. |
---|
103 | * Reset timeslice and yield the processor functions both use this routine, |
---|
104 | * therefore if reset is true and this is the only thread on the queue then |
---|
105 | * the timeslice counter is reset. The heir THREAD will be updated if the |
---|
106 | * running is also the currently the heir. |
---|
107 | * |
---|
108 | * @param[in] scheduler The scheduler instance. |
---|
109 | * @param[in,out] the_thread The yielding thread. |
---|
110 | */ |
---|
111 | Scheduler_Void_or_thread _Scheduler_simple_Yield( |
---|
112 | const Scheduler_Control *scheduler, |
---|
113 | Thread_Control *the_thread |
---|
114 | ); |
---|
115 | |
---|
116 | /** |
---|
117 | * @brief Remove a simple-priority-based thread from the queue. |
---|
118 | * |
---|
119 | * This routine removes @a the_thread from the scheduling decision, |
---|
120 | * that is, removes it from the ready queue. It performs |
---|
121 | * any necessary scheduling operations including the selection of |
---|
122 | * a new heir thread. |
---|
123 | * |
---|
124 | * @param[in] scheduler The scheduler instance. |
---|
125 | * @param[in] the_thread is the thread that is to be blocked |
---|
126 | */ |
---|
127 | void _Scheduler_simple_Block( |
---|
128 | const Scheduler_Control *scheduler, |
---|
129 | Thread_Control *the_thread |
---|
130 | ); |
---|
131 | |
---|
132 | /** |
---|
133 | * @brief Unblock a simple-priority-based thread. |
---|
134 | * |
---|
135 | * This routine adds @a the_thread to the scheduling decision, |
---|
136 | * that is, adds it to the ready queue and |
---|
137 | * updates any appropriate scheduling variables, for example the heir thread. |
---|
138 | * |
---|
139 | * @param[in] scheduler The scheduler instance. |
---|
140 | * @param[in] the_thread is the thread that is to be unblocked |
---|
141 | */ |
---|
142 | Scheduler_Void_or_thread _Scheduler_simple_Unblock( |
---|
143 | const Scheduler_Control *scheduler, |
---|
144 | Thread_Control *the_thread |
---|
145 | ); |
---|
146 | |
---|
147 | Scheduler_Void_or_thread _Scheduler_simple_Update_priority( |
---|
148 | const Scheduler_Control *scheduler, |
---|
149 | Thread_Control *the_thread |
---|
150 | ); |
---|
151 | |
---|
152 | /**@}*/ |
---|
153 | |
---|
154 | #ifdef __cplusplus |
---|
155 | } |
---|
156 | #endif |
---|
157 | |
---|
158 | #endif |
---|
159 | /* end of include file */ |
---|