Mercurial > nand-ecoscentric
comparison packages/kernel/current/include/mlqueue.hxx @ 177:4c750ce71ae3
Merge from eCos master repository on 2001-08-10-19:22:57-BST
| author | jlarmour |
|---|---|
| date | Fri, 10 Aug 2001 19:27:55 +0000 |
| parents | 25e238959bae |
| children | e0c0827131d1 |
comparison
equal
deleted
inserted
replaced
| 176:3902ef905c9c | 177:4c750ce71ae3 |
|---|---|
| 90 | 90 |
| 91 // set default scheduling info value for thread constructors. | 91 // set default scheduling info value for thread constructors. |
| 92 #define CYG_SCHED_DEFAULT_INFO CYG_THREAD_MAX_PRIORITY | 92 #define CYG_SCHED_DEFAULT_INFO CYG_THREAD_MAX_PRIORITY |
| 93 | 93 |
| 94 // ------------------------------------------------------------------------- | 94 // ------------------------------------------------------------------------- |
| 95 // scheduler Run queue object | |
| 96 | |
| 97 typedef Cyg_CList_T<Cyg_Thread> Cyg_RunQueue; | |
| 98 | |
| 99 // ------------------------------------------------------------------------- | |
| 95 // Thread queue implementation. | 100 // Thread queue implementation. |
| 96 // This class provides the (scheduler specific) implementation of the | 101 // This class provides the (scheduler specific) implementation of the |
| 97 // thread queue class. | 102 // thread queue class. |
| 98 | 103 |
| 99 class Cyg_ThreadQueue_Implementation | 104 class Cyg_ThreadQueue_Implementation |
| 100 : public Cyg_CList_T<Cyg_Thread> | 105 : public Cyg_CList_T<Cyg_Thread> |
| 101 { | 106 { |
| 102 friend class Cyg_Scheduler_Implementation; | 107 friend class Cyg_Scheduler_Implementation; |
| 103 friend class Cyg_SchedThread_Implementation; | 108 friend class Cyg_SchedThread_Implementation; |
| 104 friend class Cyg_SchedulerThreadQueue_Implementation; | |
| 105 | 109 |
| 106 void set_thread_queue(Cyg_Thread *thread, | 110 void set_thread_queue(Cyg_Thread *thread, |
| 107 Cyg_ThreadQueue *tq ); | 111 Cyg_ThreadQueue *tq ); |
| 108 | 112 |
| 109 protected: | 113 protected: |
| 122 Cyg_Thread *dequeue(); | 126 Cyg_Thread *dequeue(); |
| 123 | 127 |
| 124 // Remove thread from queue | 128 // Remove thread from queue |
| 125 void remove(Cyg_Thread *thread); | 129 void remove(Cyg_Thread *thread); |
| 126 | 130 |
| 127 }; | |
| 128 | |
| 129 // thread queue used exclusively by the scheduler, with simpler enqueueing | |
| 130 | |
| 131 class Cyg_SchedulerThreadQueue_Implementation | |
| 132 : public Cyg_ThreadQueue_Implementation | |
| 133 { | |
| 134 public: | |
| 135 void enqueue(Cyg_Thread *thread); // Add thread to queue | |
| 136 }; | 131 }; |
| 137 | 132 |
| 138 // ------------------------------------------------------------------------- | 133 // ------------------------------------------------------------------------- |
| 139 // This class contains the implementation details of the scheduler, and | 134 // This class contains the implementation details of the scheduler, and |
| 140 // provides a standard API for accessing it. | 135 // provides a standard API for accessing it. |
| 143 : public Cyg_Scheduler_Base | 138 : public Cyg_Scheduler_Base |
| 144 { | 139 { |
| 145 friend class Cyg_ThreadQueue_Implementation; | 140 friend class Cyg_ThreadQueue_Implementation; |
| 146 friend class Cyg_SchedThread_Implementation; | 141 friend class Cyg_SchedThread_Implementation; |
| 147 friend class Cyg_HardwareThread; | 142 friend class Cyg_HardwareThread; |
| 143 friend void cyg_scheduler_set_need_reschedule(); | |
| 148 | 144 |
| 149 // Mask of which run queues have ready threads | 145 // Mask of which run queues have ready threads |
| 150 cyg_sched_bitmap queue_map; | 146 cyg_sched_bitmap queue_map; |
| 151 | 147 |
| 152 // Each run queue is a double linked circular list of threads. | 148 // Each run queue is a double linked circular list of threads. |
| 153 // These pointers point to the head element of each list. | 149 // These pointers point to the head element of each list. |
| 154 Cyg_SchedulerThreadQueue_Implementation run_queue[CYGNUM_KERNEL_SCHED_PRIORITIES]; | 150 Cyg_RunQueue run_queue[CYGNUM_KERNEL_SCHED_PRIORITIES]; |
| 151 | |
| 152 #ifdef CYGPKG_KERNEL_SMP_SUPPORT | |
| 153 | |
| 154 // In SMP systems we additionally keep a counter for each priority | |
| 155 // of the number of pending but not running threads in each queue. | |
| 156 | |
| 157 cyg_uint32 pending[CYGNUM_KERNEL_SCHED_PRIORITIES]; | |
| 158 | |
| 159 cyg_sched_bitmap pending_map; | |
| 160 | |
| 161 #endif | |
| 155 | 162 |
| 156 protected: | 163 protected: |
| 157 | 164 |
| 158 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE | 165 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE |
| 159 | 166 |
| 160 // Timeslice counter. This is decremented on each | 167 // Timeslice counter. This is decremented on each |
| 161 // clock tick, and a timeslice is performed each | 168 // clock tick, and a timeslice is performed each |
| 162 // time it zeroes. | 169 // time it zeroes. |
| 163 | 170 |
| 164 static cyg_ucount32 timeslice_count; | 171 static cyg_ucount32 timeslice_count[CYGNUM_KERNEL_CPU_MAX] |
| 172 CYGBLD_ANNOTATE_VARIABLE_SCHED; | |
| 165 | 173 |
| 166 static void reset_timeslice_count(); | 174 static void reset_timeslice_count(); |
| 167 | 175 |
| 168 #endif | 176 #endif |
| 169 | 177 |
| 189 void deregister_thread(Cyg_Thread *thread); | 197 void deregister_thread(Cyg_Thread *thread); |
| 190 | 198 |
| 191 // Test the given priority for uniqueness | 199 // Test the given priority for uniqueness |
| 192 cyg_bool unique( cyg_priority priority); | 200 cyg_bool unique( cyg_priority priority); |
| 193 | 201 |
| 202 // Set need_reschedule if the supplied thread is of lower | |
| 203 // priority than any that are currently running. | |
| 204 static void set_need_reschedule( Cyg_Thread *thread ); | |
| 205 static void set_need_reschedule(); | |
| 206 | |
| 207 public: | |
| 208 void set_idle_thread( Cyg_Thread *thread, HAL_SMP_CPU_TYPE cpu ); | |
| 209 | |
| 194 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE | 210 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE |
| 195 | 211 |
| 196 // If timeslicing is enbled, define a scheduler | 212 // If timeslicing is enbled, define a scheduler |
| 197 // entry point to do timeslicing. This will be | 213 // entry points to do timeslicing. This will be |
| 198 // called from the RTC DSR. | 214 // called from the RTC DSR. |
| 199 public: | 215 public: |
| 200 void timeslice(); | 216 void timeslice(); |
| 217 void timeslice_cpu(); | |
| 201 | 218 |
| 202 #endif | 219 #endif |
| 203 | 220 |
| 204 }; | 221 }; |
| 205 | 222 |
| 206 // ------------------------------------------------------------------------- | 223 // ------------------------------------------------------------------------- |
| 207 // Cyg_Scheduler_Implementation inlines | 224 // Cyg_Scheduler_Implementation inlines |
| 208 | 225 |
| 226 inline void Cyg_Scheduler_Implementation::set_need_reschedule() | |
| 227 { | |
| 228 need_reschedule[CYG_KERNEL_CPU_THIS()] = true; | |
| 229 } | |
| 230 | |
| 209 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE | 231 #ifdef CYGSEM_KERNEL_SCHED_TIMESLICE |
| 210 | 232 |
| 211 inline void Cyg_Scheduler_Implementation::reset_timeslice_count() | 233 inline void Cyg_Scheduler_Implementation::reset_timeslice_count() |
| 212 { | 234 { |
| 213 timeslice_count = CYGNUM_KERNEL_SCHED_TIMESLICE_TICKS; | 235 timeslice_count[CYG_KERNEL_CPU_THIS()] = CYGNUM_KERNEL_SCHED_TIMESLICE_TICKS; |
| 214 } | 236 } |
| 215 | 237 |
| 216 #endif | 238 #endif |
| 217 | 239 |
| 218 // ------------------------------------------------------------------------- | 240 // ------------------------------------------------------------------------- |
| 223 class Cyg_SchedThread_Implementation | 245 class Cyg_SchedThread_Implementation |
| 224 : public Cyg_DNode_T<Cyg_Thread> | 246 : public Cyg_DNode_T<Cyg_Thread> |
| 225 { | 247 { |
| 226 friend class Cyg_Scheduler_Implementation; | 248 friend class Cyg_Scheduler_Implementation; |
| 227 friend class Cyg_ThreadQueue_Implementation; | 249 friend class Cyg_ThreadQueue_Implementation; |
| 228 friend class Cyg_SchedulerThreadQueue_Implementation; | |
| 229 | 250 |
| 230 protected: | 251 protected: |
| 231 | 252 |
| 232 cyg_priority priority; // current thread priority | 253 cyg_priority priority; // current thread priority |
| 233 | 254 |
| 255 #ifdef CYGPKG_KERNEL_SMP_SUPPORT | |
| 256 HAL_SMP_CPU_TYPE cpu; // CPU id of cpu currently running | |
| 257 // this thread, or CYG_KERNEL_CPU_NONE | |
| 258 // if not running. | |
| 259 #endif | |
| 260 | |
| 234 Cyg_SchedThread_Implementation(CYG_ADDRWORD sched_info); | 261 Cyg_SchedThread_Implementation(CYG_ADDRWORD sched_info); |
| 235 | 262 |
| 236 void yield(); // Yield CPU to next thread | 263 void yield(); // Yield CPU to next thread |
| 237 | 264 |
| 238 static void rotate_queue( cyg_priority pri ); | 265 static void rotate_queue( cyg_priority pri ); |
