1 | /** |
---|
2 | * @file rtems/score/scheduler.inl |
---|
3 | * |
---|
4 | * This inline file contains all of the inlined routines associated with |
---|
5 | * the manipulation of the scheduler. |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * Copyright (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_SCHEDULER_H |
---|
20 | # error "Never use <rtems/score/scheduler.inl> directly; include <rtems/score/scheduler.h> instead." |
---|
21 | #endif |
---|
22 | |
---|
23 | #ifndef _RTEMS_SCORE_SCHEDULER_INL |
---|
24 | #define _RTEMS_SCORE_SCHEDULER_INL |
---|
25 | |
---|
26 | /** |
---|
27 | * @addtogroup ScoreScheduler |
---|
28 | * @{ |
---|
29 | */ |
---|
30 | |
---|
31 | /** |
---|
32 | * The preferred method to add a new scheduler is to define the jump table |
---|
33 | * entries and add a case to the _Scheduler_Initialize routine. |
---|
34 | * |
---|
35 | * Generic scheduling implementations that rely on the ready queue only can |
---|
36 | * be found in the _Scheduler_queue_XXX functions. |
---|
37 | * |
---|
38 | */ |
---|
39 | |
---|
40 | /* Passing the Scheduler_Control* to these functions allows for multiple |
---|
41 | * scheduler's to exist simultaneously, which could be useful on an SMP |
---|
42 | * system. Then remote Schedulers may be accessible. How to protect such |
---|
43 | * accesses remains an open problem. |
---|
44 | */ |
---|
45 | |
---|
46 | /** @brief _Scheduler_Schedule |
---|
47 | * |
---|
48 | * This kernel routine implements the scheduling decision logic for |
---|
49 | * the scheduler. It does NOT dispatch. |
---|
50 | */ |
---|
51 | RTEMS_INLINE_ROUTINE void _Scheduler_Schedule( void ) |
---|
52 | { |
---|
53 | _Scheduler.Operations.schedule(); |
---|
54 | } |
---|
55 | |
---|
56 | /** @brief _Scheduler_Yield |
---|
57 | * |
---|
58 | * This routine is invoked when a thread wishes to voluntarily |
---|
59 | * transfer control of the processor to another thread. This routine |
---|
60 | * always operates on the scheduler that 'owns' the currently executing |
---|
61 | * thread. |
---|
62 | */ |
---|
63 | RTEMS_INLINE_ROUTINE void _Scheduler_Yield( void ) |
---|
64 | { |
---|
65 | _Scheduler.Operations.yield(); |
---|
66 | } |
---|
67 | |
---|
68 | /** @brief _Scheduler_Block |
---|
69 | * |
---|
70 | * This routine removes @a the_thread from the scheduling decision for |
---|
71 | * the scheduler. The primary task is to remove the thread from the |
---|
72 | * ready queue. It performs any necessary schedulering operations |
---|
73 | * including the selection of a new heir thread. |
---|
74 | */ |
---|
75 | RTEMS_INLINE_ROUTINE void _Scheduler_Block( |
---|
76 | Thread_Control *the_thread |
---|
77 | ) |
---|
78 | { |
---|
79 | _Scheduler.Operations.block( the_thread ); |
---|
80 | } |
---|
81 | |
---|
82 | /** @brief _Scheduler_Unblock |
---|
83 | * |
---|
84 | * This routine adds @a the_thread to the scheduling decision for |
---|
85 | * the scheduler. The primary task is to add the thread to the |
---|
86 | * ready queue per the schedulering policy and update any appropriate |
---|
87 | * scheduling variables, for example the heir thread. |
---|
88 | */ |
---|
89 | RTEMS_INLINE_ROUTINE void _Scheduler_Unblock( |
---|
90 | Thread_Control *the_thread |
---|
91 | ) |
---|
92 | { |
---|
93 | _Scheduler.Operations.unblock( the_thread ); |
---|
94 | } |
---|
95 | |
---|
96 | /** @brief _Scheduler_Allocate |
---|
97 | * |
---|
98 | * This routine allocates @a the_thread->scheduler |
---|
99 | */ |
---|
100 | RTEMS_INLINE_ROUTINE void* _Scheduler_Allocate( |
---|
101 | Thread_Control *the_thread |
---|
102 | ) |
---|
103 | { |
---|
104 | return _Scheduler.Operations.allocate( the_thread ); |
---|
105 | } |
---|
106 | |
---|
107 | /** @brief _Scheduler_Free |
---|
108 | * |
---|
109 | * This routine frees @a the_thread->scheduler |
---|
110 | */ |
---|
111 | RTEMS_INLINE_ROUTINE void _Scheduler_Free( |
---|
112 | Thread_Control *the_thread |
---|
113 | ) |
---|
114 | { |
---|
115 | return _Scheduler.Operations.free( the_thread ); |
---|
116 | } |
---|
117 | |
---|
118 | /** @brief _Scheduler_Update |
---|
119 | * |
---|
120 | * This routine updates @a the_thread->scheduler |
---|
121 | */ |
---|
122 | RTEMS_INLINE_ROUTINE void _Scheduler_Update( |
---|
123 | Thread_Control *the_thread |
---|
124 | ) |
---|
125 | { |
---|
126 | _Scheduler.Operations.update( the_thread ); |
---|
127 | } |
---|
128 | |
---|
129 | /** @brief _Scheduler_Enqueue |
---|
130 | * |
---|
131 | * This routine enqueue @a the_thread->scheduler |
---|
132 | */ |
---|
133 | RTEMS_INLINE_ROUTINE void _Scheduler_Enqueue( |
---|
134 | Thread_Control *the_thread |
---|
135 | ) |
---|
136 | { |
---|
137 | _Scheduler.Operations.enqueue( the_thread ); |
---|
138 | } |
---|
139 | |
---|
140 | /** @brief _Scheduler_Enqueue_first |
---|
141 | * |
---|
142 | * This routine enqueue_first @a the_thread->scheduler |
---|
143 | */ |
---|
144 | RTEMS_INLINE_ROUTINE void _Scheduler_Enqueue_first( |
---|
145 | Thread_Control *the_thread |
---|
146 | ) |
---|
147 | { |
---|
148 | _Scheduler.Operations.enqueue_first( the_thread ); |
---|
149 | } |
---|
150 | |
---|
151 | /** @brief _Scheduler_Extract |
---|
152 | * |
---|
153 | * This routine extract @a the_thread->scheduler |
---|
154 | */ |
---|
155 | RTEMS_INLINE_ROUTINE void _Scheduler_Extract( |
---|
156 | Thread_Control *the_thread |
---|
157 | ) |
---|
158 | { |
---|
159 | _Scheduler.Operations.extract( the_thread ); |
---|
160 | } |
---|
161 | |
---|
162 | /** |
---|
163 | * @brief Scheduler Priority compare |
---|
164 | * |
---|
165 | * This routine compares two priorities. |
---|
166 | */ |
---|
167 | RTEMS_INLINE_ROUTINE int _Scheduler_Priority_compare( |
---|
168 | Priority_Control p1, |
---|
169 | Priority_Control p2 |
---|
170 | ) |
---|
171 | { |
---|
172 | return _Scheduler.Operations.priority_compare(p1, p2); |
---|
173 | } |
---|
174 | |
---|
175 | /** |
---|
176 | * @brief Scheduler Release job |
---|
177 | * |
---|
178 | * This routine is called when a new period of task is issued. |
---|
179 | */ |
---|
180 | RTEMS_INLINE_ROUTINE void _Scheduler_Release_job( |
---|
181 | Thread_Control *the_thread, |
---|
182 | uint32_t length |
---|
183 | ) |
---|
184 | { |
---|
185 | _Scheduler.Operations.release_job(the_thread, length); |
---|
186 | } |
---|
187 | |
---|
188 | /** @brief Scheduler Method Invoked at Each Clock Tick |
---|
189 | * |
---|
190 | * This method is invoked at each clock tick to allow the scheduler |
---|
191 | * implementation to perform any activities required. For the |
---|
192 | * scheduler which support standard RTEMS features, this includes |
---|
193 | * time-slicing management. |
---|
194 | */ |
---|
195 | RTEMS_INLINE_ROUTINE void _Scheduler_Tick( void ) |
---|
196 | { |
---|
197 | _Scheduler.Operations.tick(); |
---|
198 | } |
---|
199 | |
---|
200 | /**@}*/ |
---|
201 | |
---|
202 | #endif |
---|
203 | /* end of include file */ |
---|