comparison packages/kernel/current/include/mlqueue.hxx @ 115:6ed91473a1cd ecos-sw-2000-08-21

Merge from eCos master repository on 2000-08-21-22:40:54-BST
author jlarmour
date Fri, 25 Aug 2000 17:32:38 +0000
parents bf00f99aec69
children 0ec04793409a
comparison
equal deleted inserted replaced
114:5ad2b71d525e 115:6ed91473a1cd
32 // 32 //
33 //####COPYRIGHTEND#### 33 //####COPYRIGHTEND####
34 //========================================================================== 34 //==========================================================================
35 //#####DESCRIPTIONBEGIN#### 35 //#####DESCRIPTIONBEGIN####
36 // 36 //
37 // Author(s): nickg 37 // Author(s): nickg
38 // Contributors: nickg 38 // Contributors: jlarmour
39 // Date: 1997-09-10 39 // Date: 1997-09-10
40 // Purpose: Define multilevel queue scheduler implementation 40 // Purpose: Define multilevel queue scheduler implementation
41 // Description: The classes defined here are used as base classes 41 // Description: The classes defined here are used as base classes
42 // by the common classes that define schedulers and thread 42 // by the common classes that define schedulers and thread
43 // things. The MLQ scheduler in various configurations 43 // things. The MLQ scheduler in various configurations
44 // provides standard FIFO, round-robin and single priority 44 // provides standard FIFO, round-robin and single priority
45 // schedulers. 45 // schedulers.
46 // Usage: Included according to configuration by 46 // Usage: Included according to configuration by
47 // <cyg/kernel/sched.hxx> 47 // <cyg/kernel/sched.hxx>
48 // 48 //
49 //####DESCRIPTIONEND#### 49 //####DESCRIPTIONEND####
50 // 50 //
51 //========================================================================== 51 //==========================================================================
52 52
97 97
98 class Cyg_ThreadQueue_Implementation 98 class Cyg_ThreadQueue_Implementation
99 { 99 {
100 friend class Cyg_Scheduler_Implementation; 100 friend class Cyg_Scheduler_Implementation;
101 friend class Cyg_SchedThread_Implementation; 101 friend class Cyg_SchedThread_Implementation;
102 102 friend class Cyg_SchedulerThreadQueue_Implementation;
103
104 void set_thread_queue(Cyg_Thread *thread,
105 Cyg_ThreadQueue *tq );
106
103 Cyg_Thread *queue; 107 Cyg_Thread *queue;
104 108
105 protected: 109 protected:
106 110
107 // API used by Cyg_ThreadQueue 111 // API used by Cyg_ThreadQueue
115 Cyg_Thread *highpri(); 119 Cyg_Thread *highpri();
116 120
117 // remove first thread on queue 121 // remove first thread on queue
118 Cyg_Thread *dequeue(); 122 Cyg_Thread *dequeue();
119 123
120 // remove specified thread from queue 124 // remove specified thread from queue
121 void remove(Cyg_Thread *thread); 125 void remove(Cyg_Thread *thread);
122 126
123 // test if queue is empty 127 // test if queue is empty
124 cyg_bool empty(); 128 cyg_bool empty();
125 129
131 135
132 inline cyg_bool Cyg_ThreadQueue_Implementation::empty() 136 inline cyg_bool Cyg_ThreadQueue_Implementation::empty()
133 { 137 {
134 return queue == NULL; 138 return queue == NULL;
135 } 139 }
140
141 // thread queue used exclusively by the scheduler, with simpler enqueueing
142
143 class Cyg_SchedulerThreadQueue_Implementation
144 : public Cyg_ThreadQueue_Implementation
145 {
146 void enqueue(Cyg_Thread *thread); // Add thread to queue
147 };
136 148
137 // ------------------------------------------------------------------------- 149 // -------------------------------------------------------------------------
138 // This class contains the implementation details of the scheduler, and 150 // This class contains the implementation details of the scheduler, and
139 // provides a standard API for accessing it. 151 // provides a standard API for accessing it.
140 152
148 // Mask of which run queues have ready threads 160 // Mask of which run queues have ready threads
149 cyg_sched_bitmap queue_map; 161 cyg_sched_bitmap queue_map;
150 162
151 // Each run queue is a double linked circular list of threads. 163 // Each run queue is a double linked circular list of threads.
152 // These pointers point to the head element of each list. 164 // These pointers point to the head element of each list.
153 Cyg_ThreadQueue_Implementation run_queue[CYGNUM_KERNEL_SCHED_PRIORITIES]; 165 Cyg_SchedulerThreadQueue_Implementation run_queue[CYGNUM_KERNEL_SCHED_PRIORITIES];
154 166
155 protected: 167 protected:
156 168
157 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE 169 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE
158 170
161 // time it zeroes. 173 // time it zeroes.
162 174
163 static cyg_ucount32 timeslice_count; 175 static cyg_ucount32 timeslice_count;
164 176
165 static void reset_timeslice_count(); 177 static void reset_timeslice_count();
166 178
167 #endif 179 #endif
168 180
169 Cyg_Scheduler_Implementation(); // Constructor 181 Cyg_Scheduler_Implementation(); // Constructor
170 182
171 // The following functions provide the scheduler implementation 183 // The following functions provide the scheduler implementation
172 // interface to the Cyg_Scheduler class. These are protected 184 // interface to the Cyg_Scheduler class. These are protected
173 // so that only the scheduler can call them. 185 // so that only the scheduler can call them.
195 // If timeslicing is enbled, define a scheduler 207 // If timeslicing is enbled, define a scheduler
196 // entry point to do timeslicing. This will be 208 // entry point to do timeslicing. This will be
197 // called from the RTC DSR. 209 // called from the RTC DSR.
198 public: 210 public:
199 void timeslice(); 211 void timeslice();
200 212
201 #endif 213 #endif
202 214
203 }; 215 };
204 216
205 // ------------------------------------------------------------------------- 217 // -------------------------------------------------------------------------
221 233
222 class Cyg_SchedThread_Implementation 234 class Cyg_SchedThread_Implementation
223 { 235 {
224 friend class Cyg_Scheduler_Implementation; 236 friend class Cyg_Scheduler_Implementation;
225 friend class Cyg_ThreadQueue_Implementation; 237 friend class Cyg_ThreadQueue_Implementation;
238 friend class Cyg_SchedulerThreadQueue_Implementation;
226 239
227 Cyg_Thread *next; // next thread in queue 240 Cyg_Thread *next; // next thread in queue
228 Cyg_Thread *prev; // previous thread in queue 241 Cyg_Thread *prev; // previous thread in queue
229 242
230 void insert( Cyg_Thread *thread ); // Insert thread in front of this 243 void insert( Cyg_Thread *thread ); // Insert thread in front of this
243 // Rotate that run queue 256 // Rotate that run queue
244 257
245 void to_queue_head( void ); // Move this thread to the head 258 void to_queue_head( void ); // Move this thread to the head
246 // of its queue (not necessarily 259 // of its queue (not necessarily
247 // a scheduler queue) 260 // a scheduler queue)
248 }; 261
262 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE_ENABLE
263
264 // This defines whether this thread is subject to timeslicing.
265 // If false, timeslice expiry has no effect on the thread.
266
267 cyg_bool timeslice_enabled;
268
269 public:
270
271 void timeslice_enable();
272
273 void timeslice_disable();
274
275 #endif
276
277 };
278
279 // -------------------------------------------------------------------------
280 // Cyg_SchedThread_Implementation inlines.
281
282 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE_ENABLE
283
284 inline void Cyg_SchedThread_Implementation::timeslice_enable()
285 {
286 timeslice_enabled = true;
287 }
288
289 inline void Cyg_SchedThread_Implementation::timeslice_disable()
290 {
291 timeslice_enabled = false;
292 }
293
294 #endif
295
249 296
250 // ------------------------------------------------------------------------- 297 // -------------------------------------------------------------------------
251 #endif // ifndef CYGONCE_KERNEL_MLQUEUE_HXX 298 #endif // ifndef CYGONCE_KERNEL_MLQUEUE_HXX
252 // EOF mlqueue.hxx 299 // EOF mlqueue.hxx