comparison packages/kernel/current/include/mlqueue.hxx @ 148:8f2f7615e727

Merge from eCos master repository on 2001-01-12-06:43:03-GMT
author jlarmour
date Fri, 12 Jan 2001 08:11:46 +0000
parents 0ae0bc38e387
children 25e238959bae
comparison
equal deleted inserted replaced
147:d397fc472bcf 148:8f2f7615e727
50 // 50 //
51 //========================================================================== 51 //==========================================================================
52 52
53 #include <cyg/kernel/ktypes.h> 53 #include <cyg/kernel/ktypes.h>
54 54
55 #include <cyg/infra/clist.hxx> // List implementation
56
55 // ------------------------------------------------------------------------- 57 // -------------------------------------------------------------------------
56 // The macro CYGNUM_KERNEL_SCHED_PRIORITIES contains the number of priorities 58 // The macro CYGNUM_KERNEL_SCHED_PRIORITIES contains the number of priorities
57 // supported by the scheduler. 59 // supported by the scheduler.
58 60
59 #ifndef CYGNUM_KERNEL_SCHED_PRIORITIES 61 #ifndef CYGNUM_KERNEL_SCHED_PRIORITIES
93 // Thread queue implementation. 95 // Thread queue implementation.
94 // This class provides the (scheduler specific) implementation of the 96 // This class provides the (scheduler specific) implementation of the
95 // thread queue class. 97 // thread queue class.
96 98
97 class Cyg_ThreadQueue_Implementation 99 class Cyg_ThreadQueue_Implementation
100 : public Cyg_CList_T<Cyg_Thread>
98 { 101 {
99 friend class Cyg_Scheduler_Implementation; 102 friend class Cyg_Scheduler_Implementation;
100 friend class Cyg_SchedThread_Implementation; 103 friend class Cyg_SchedThread_Implementation;
101 friend class Cyg_SchedulerThreadQueue_Implementation; 104 friend class Cyg_SchedulerThreadQueue_Implementation;
102 105
103 void set_thread_queue(Cyg_Thread *thread, 106 void set_thread_queue(Cyg_Thread *thread,
104 Cyg_ThreadQueue *tq ); 107 Cyg_ThreadQueue *tq );
105 108
106 Cyg_Thread *queue;
107
108 protected: 109 protected:
109 110
110 // API used by Cyg_ThreadQueue 111 // API used by Cyg_ThreadQueue
111 112
112 Cyg_ThreadQueue_Implementation(); // Constructor 113 Cyg_ThreadQueue_Implementation() {}; // Constructor
113 114
114 // Add thread to queue 115 // Add thread to queue
115 void enqueue(Cyg_Thread *thread); 116 void enqueue(Cyg_Thread *thread);
116 117
117 // return first thread on queue 118 // return first thread on queue
118 Cyg_Thread *highpri(); 119 Cyg_Thread *highpri();
119 120
120 // remove first thread on queue 121 // remove first thread on queue
121 Cyg_Thread *dequeue(); 122 Cyg_Thread *dequeue();
122 123
123 // remove specified thread from queue 124 };
124 void remove(Cyg_Thread *thread);
125
126 // test if queue is empty
127 cyg_bool empty();
128
129 void rotate(); // Rotate the queue
130
131 void to_head(Cyg_Thread *thread);
132
133 };
134
135 inline cyg_bool Cyg_ThreadQueue_Implementation::empty()
136 {
137 return queue == NULL;
138 }
139 125
140 // thread queue used exclusively by the scheduler, with simpler enqueueing 126 // thread queue used exclusively by the scheduler, with simpler enqueueing
141 127
142 class Cyg_SchedulerThreadQueue_Implementation 128 class Cyg_SchedulerThreadQueue_Implementation
143 : public Cyg_ThreadQueue_Implementation 129 : public Cyg_ThreadQueue_Implementation
230 // Scheduler thread implementation. 216 // Scheduler thread implementation.
231 // This class provides the implementation of the scheduler specific parts 217 // This class provides the implementation of the scheduler specific parts
232 // of each thread. 218 // of each thread.
233 219
234 class Cyg_SchedThread_Implementation 220 class Cyg_SchedThread_Implementation
221 : public Cyg_DNode_T<Cyg_Thread>
235 { 222 {
236 friend class Cyg_Scheduler_Implementation; 223 friend class Cyg_Scheduler_Implementation;
237 friend class Cyg_ThreadQueue_Implementation; 224 friend class Cyg_ThreadQueue_Implementation;
238 friend class Cyg_SchedulerThreadQueue_Implementation; 225 friend class Cyg_SchedulerThreadQueue_Implementation;
239 226
240 Cyg_Thread *next; // next thread in queue
241 Cyg_Thread *prev; // previous thread in queue
242
243 void insert( Cyg_Thread *thread ); // Insert thread in front of this
244
245 void remove(); // remove this from queue
246
247 protected: 227 protected:
248 228
249 cyg_priority priority; // current thread priority 229 cyg_priority priority; // current thread priority
250 230
251 Cyg_SchedThread_Implementation(CYG_ADDRWORD sched_info); 231 Cyg_SchedThread_Implementation(CYG_ADDRWORD sched_info);