1 | /** |
---|
2 | * @file rtems/score/schedulerpriority.h |
---|
3 | * |
---|
4 | * This include file contains all the constants and structures associated |
---|
5 | * with the manipulation of threads for the priority-based scheduler. |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * Copryight (c) 2010 Gedare Bloom. |
---|
10 | * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | * |
---|
16 | * $Id$ |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _RTEMS_SCORE_SCHEDULERPRIORITY_H |
---|
20 | #define _RTEMS_SCORE_SCHEDULERPRIORITY_H |
---|
21 | |
---|
22 | #include <rtems/score/chain.h> |
---|
23 | #include <rtems/score/priority.h> |
---|
24 | #include <rtems/score/scheduler.h> |
---|
25 | |
---|
26 | #ifdef __cplusplus |
---|
27 | extern "C" { |
---|
28 | #endif |
---|
29 | |
---|
30 | /** |
---|
31 | * @addtogroup ScoreScheduler |
---|
32 | * |
---|
33 | */ |
---|
34 | /**@{*/ |
---|
35 | |
---|
36 | /** |
---|
37 | * Entry points for the Deterministic Priority Based Scheduler. |
---|
38 | */ |
---|
39 | #define SCHEDULER_PRIORITY_ENTRY_POINTS \ |
---|
40 | { \ |
---|
41 | _Scheduler_priority_Initialize, /* initialize entry point */ \ |
---|
42 | _Scheduler_priority_Schedule, /* schedule entry point */ \ |
---|
43 | _Scheduler_priority_Yield, /* yield entry point */ \ |
---|
44 | _Scheduler_priority_Block, /* block entry point */ \ |
---|
45 | _Scheduler_priority_Unblock, /* unblock entry point */ \ |
---|
46 | _Scheduler_priority_Allocate, /* allocate entry point */ \ |
---|
47 | _Scheduler_priority_Free, /* free entry point */ \ |
---|
48 | _Scheduler_priority_Update, /* update entry point */ \ |
---|
49 | _Scheduler_priority_Enqueue, /* enqueue entry point */ \ |
---|
50 | _Scheduler_priority_Enqueue_first, /* enqueue_first entry point */ \ |
---|
51 | _Scheduler_priority_Extract /* extract entry point */ \ |
---|
52 | } |
---|
53 | |
---|
54 | /** |
---|
55 | * Per-thread data related to the _Scheduler_PRIORITY scheduling policy. |
---|
56 | */ |
---|
57 | typedef struct { |
---|
58 | /** This field points to the Ready FIFO for this thread's priority. */ |
---|
59 | Chain_Control *ready_chain; |
---|
60 | |
---|
61 | /** This field contains precalculated priority map indices. */ |
---|
62 | Priority_bit_map_Information Priority_map; |
---|
63 | } Scheduler_priority_Per_thread; |
---|
64 | |
---|
65 | /** |
---|
66 | * This routine initializes the priority scheduler. |
---|
67 | */ |
---|
68 | void _Scheduler_priority_Initialize(void); |
---|
69 | |
---|
70 | /** |
---|
71 | * This routine removes @a the_thread from the scheduling decision, |
---|
72 | * that is, removes it from the ready queue. It performs |
---|
73 | * any necessary scheduling operations including the selection of |
---|
74 | * a new heir thread. |
---|
75 | * |
---|
76 | * @param[in] the_thread is the thread to be blocked |
---|
77 | */ |
---|
78 | void _Scheduler_priority_Block( |
---|
79 | Thread_Control *the_thread |
---|
80 | ); |
---|
81 | |
---|
82 | /** |
---|
83 | * This kernel routine sets the heir thread to be the next ready thread |
---|
84 | * by invoking the_scheduler->ready_queue->operations->first(). |
---|
85 | */ |
---|
86 | void _Scheduler_priority_Schedule(void); |
---|
87 | |
---|
88 | /** |
---|
89 | * This routine allocates @a the_thread->scheduler. |
---|
90 | * |
---|
91 | * @param[in] the_thread is the thread the scheduler is allocating |
---|
92 | * management memory for |
---|
93 | */ |
---|
94 | void * _Scheduler_priority_Allocate( |
---|
95 | Thread_Control *the_thread |
---|
96 | ); |
---|
97 | |
---|
98 | /** |
---|
99 | * This routine frees @a the_thread->scheduler. |
---|
100 | * |
---|
101 | * @param[in] the_thread is the thread whose scheduler specific information |
---|
102 | * will be deallocated. |
---|
103 | */ |
---|
104 | void _Scheduler_priority_Free( |
---|
105 | Thread_Control *the_thread |
---|
106 | ); |
---|
107 | |
---|
108 | /** |
---|
109 | * This routine updates @a the_thread->scheduler based on @a the_scheduler |
---|
110 | * structures and thread state. |
---|
111 | * |
---|
112 | * @param[in] the_thread will have its scheduler specific information |
---|
113 | * structure updated. |
---|
114 | */ |
---|
115 | void _Scheduler_priority_Update( |
---|
116 | Thread_Control *the_thread |
---|
117 | ); |
---|
118 | |
---|
119 | /** |
---|
120 | * This routine adds @a the_thread to the scheduling decision, |
---|
121 | * that is, adds it to the ready queue and |
---|
122 | * updates any appropriate scheduling variables, for example the heir thread. |
---|
123 | * |
---|
124 | * @param[in] the_thread will be unblocked |
---|
125 | */ |
---|
126 | void _Scheduler_priority_Unblock( |
---|
127 | Thread_Control *the_thread |
---|
128 | ); |
---|
129 | |
---|
130 | /** |
---|
131 | * This routine is invoked when a thread wishes to voluntarily |
---|
132 | * transfer control of the processor to another thread in the queue. |
---|
133 | * |
---|
134 | * This routine will remove the running THREAD from the ready queue |
---|
135 | * and place it immediately at the rear of this chain. Reset timeslice |
---|
136 | * and yield the processor functions both use this routine, therefore if |
---|
137 | * reset is true and this is the only thread on the queue then the |
---|
138 | * timeslice counter is reset. The heir THREAD will be updated if the |
---|
139 | * running is also the currently the heir. |
---|
140 | */ |
---|
141 | void _Scheduler_priority_Yield( void ); |
---|
142 | |
---|
143 | /** |
---|
144 | * This routine puts @a the_thread on to the priority-based ready queue. |
---|
145 | * |
---|
146 | * @param[in] the_thread will be enqueued at the TAIL of its priority. |
---|
147 | */ |
---|
148 | void _Scheduler_priority_Enqueue( |
---|
149 | Thread_Control *the_thread |
---|
150 | ); |
---|
151 | |
---|
152 | /** |
---|
153 | * This routine puts @a the_thread to the head of the ready queue. |
---|
154 | * For priority-based ready queues, the thread will be the first thread |
---|
155 | * at its priority level. |
---|
156 | * |
---|
157 | * @param[in] the_thread will be enqueued at the HEAD of its priority. |
---|
158 | */ |
---|
159 | void _Scheduler_priority_Enqueue_first( |
---|
160 | Thread_Control *the_thread |
---|
161 | ); |
---|
162 | |
---|
163 | /** |
---|
164 | * This routine removes a specific thread from the scheduler's set |
---|
165 | * of ready threads. |
---|
166 | * |
---|
167 | * @param[in] the_thread will be extracted from the ready set. |
---|
168 | */ |
---|
169 | void _Scheduler_priority_Extract( |
---|
170 | Thread_Control *the_thread |
---|
171 | ); |
---|
172 | |
---|
173 | /** |
---|
174 | * This is the major bit map. |
---|
175 | */ |
---|
176 | extern volatile Priority_bit_map_Control _Priority_Major_bit_map; |
---|
177 | |
---|
178 | /** |
---|
179 | * This is the minor bit map. |
---|
180 | */ |
---|
181 | extern Priority_bit_map_Control _Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT; |
---|
182 | |
---|
183 | #ifndef __RTEMS_APPLICATION__ |
---|
184 | #include <rtems/score/schedulerpriority.inl> |
---|
185 | #endif |
---|
186 | |
---|
187 | #ifdef __cplusplus |
---|
188 | } |
---|
189 | #endif |
---|
190 | |
---|
191 | /**@}*/ |
---|
192 | |
---|
193 | #endif |
---|
194 | /* end of include file */ |
---|