Mercurial > nand-ecoscentric
annotate packages/kernel/current/include/thread.hxx @ 143:6b5f480c6929 ecos-sw-2000-12-08
Merge from eCos master repository on 2000-12-08-02:09:36-GMT
| author | jlarmour |
|---|---|
| date | Fri, 08 Dec 2000 03:30:06 +0000 |
| parents | bf00f99aec69 |
| children | d397fc472bcf |
| rev | line source |
|---|---|
| 0 | 1 #ifndef CYGONCE_KERNEL_THREAD_HXX |
| 2 #define CYGONCE_KERNEL_THREAD_HXX | |
| 3 | |
| 4 //========================================================================== | |
| 5 // | |
| 2 | 6 // thread.hxx |
| 0 | 7 // |
| 2 | 8 // Thread class declarations |
| 0 | 9 // |
| 10 //========================================================================== | |
| 11 //####COPYRIGHTBEGIN#### | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
12 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
13 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
14 // The contents of this file are subject to the Red Hat eCos Public License |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
15 // Version 1.1 (the "License"); you may not use this file except in |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
16 // compliance with the License. You may obtain a copy of the License at |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
17 // http://www.redhat.com/ |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
18 // |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
19 // Software distributed under the License is distributed on an "AS IS" |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
20 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
21 // License for the specific language governing rights and limitations under |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
22 // the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
23 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
24 // The Original Code is eCos - Embedded Configurable Operating System, |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
25 // released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
26 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
27 // The Initial Developer of the Original Code is Red Hat. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
28 // Portions created by Red Hat are |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
29 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
30 // All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
31 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
32 // |
| 0 | 33 //####COPYRIGHTEND#### |
| 34 //========================================================================== | |
| 35 //#####DESCRIPTIONBEGIN#### | |
| 36 // | |
| 2 | 37 // Author(s): nickg |
| 38 // Contributors: nickg | |
| 39 // Date: 1997-09-09 | |
| 40 // Purpose: Define Thread class interfaces | |
| 41 // Description: The classes defined here collectively implement the | |
| 0 | 42 // internal API used to create, configure and manage threads. |
| 2 | 43 // Usage: #include <cyg/kernel/thread.hxx> |
| 0 | 44 // |
| 45 //####DESCRIPTIONEND#### | |
| 46 // | |
| 47 //========================================================================== | |
| 48 | |
| 49 #include <cyg/kernel/ktypes.h> | |
| 50 #include <cyg/infra/cyg_ass.h> // assertion macros | |
| 51 #include <cyg/kernel/sched.hxx> | |
| 52 #include <cyg/kernel/clock.hxx> | |
| 53 #include <cyg/kernel/except.hxx> | |
| 54 | |
| 55 #include <cyg/hal/hal_arch.h> | |
| 56 | |
| 57 // ------------------------------------------------------------------------- | |
| 58 // Miscellaneous types | |
| 59 | |
| 60 typedef void cyg_thread_entry(CYG_ADDRWORD data);// Thread entry point function | |
| 61 | |
| 62 // ------------------------------------------------------------------------- | |
| 63 // Hardware thread interface. | |
| 64 // The implementation of this class is provided by the HAL. | |
| 65 | |
| 66 class Cyg_HardwareThread | |
| 67 { | |
| 68 friend class Cyg_Scheduler; | |
| 69 | |
| 70 protected: | |
| 71 | |
| 72 CYG_ADDRESS stack_base; // pointer to base of stack area | |
| 73 | |
| 74 cyg_uint32 stack_size; // size of stack area in bytes | |
| 75 | |
| 76 #ifdef CYGFUN_KERNEL_THREADS_STACK_LIMIT | |
| 77 CYG_ADDRESS stack_limit; // movable stack limit | |
| 78 #endif | |
| 79 | |
| 80 CYG_ADDRESS stack_ptr; // pointer to saved state on stack | |
| 81 | |
| 82 cyg_thread_entry *entry_point; // main entry point (code pointer!) | |
| 83 | |
| 84 CYG_ADDRWORD entry_data; // entry point argument | |
| 85 | |
| 86 #ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT | |
| 87 | |
| 88 HAL_SavedRegisters *saved_context; // If non-zero, this points at a more | |
| 89 // interesting context than stack_ptr. | |
| 90 #endif | |
| 91 | |
| 92 Cyg_HardwareThread( | |
| 93 cyg_thread_entry *entry_point, // entry point function | |
| 94 CYG_ADDRWORD entry_data, // entry data | |
| 95 cyg_ucount32 stack_size = 0, // stack size, 0 = use default | |
| 96 CYG_ADDRESS stack_base = 0 // stack base, NULL = allocate | |
| 97 ); | |
| 98 | |
| 99 // Thread entry point. This is where all threads begin execution. | |
| 100 // This routine does a little housekeeping and then call the main | |
| 101 // entry_point specified above. | |
| 102 static void thread_entry(Cyg_Thread *thread); | |
| 103 | |
| 104 // Initialize the context of the thread to start execution at thread_entry | |
| 105 void init_context( Cyg_Thread *thread ); | |
| 106 | |
| 107 // Save current thread's context and load that of the given next thread. | |
| 108 void switch_context(Cyg_HardwareThread *next); | |
| 109 | |
| 110 // load this thread's context without saving current context | |
| 111 void load_context(); | |
| 112 | |
| 113 // attach a stack to this thread | |
| 114 void attach_stack(CYG_ADDRESS stack, cyg_uint32 stack_size); | |
| 115 | |
| 116 // detach the stack from this thread | |
| 117 CYG_ADDRESS detach_stack(); | |
| 118 | |
| 119 // Adjust the thread's saved state to call the exception | |
| 120 // handler when next executed. | |
| 121 void prepare_exception ( | |
| 122 cyg_exception_handler *exception_handler, | |
| 123 CYG_ADDRWORD exception_data, | |
| 124 cyg_code exception_number, | |
| 125 CYG_ADDRWORD exception_info | |
| 126 ); | |
| 127 | |
| 128 public: | |
| 129 | |
| 130 CYGDBG_DEFINE_CHECK_THIS | |
| 131 | |
| 132 // Get and set entry_data. | |
| 133 | |
| 134 void set_entry_data( CYG_ADDRWORD data ); | |
| 135 | |
| 136 CYG_ADDRWORD get_entry_data(); | |
| 137 | |
| 138 #ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT | |
| 139 // Return the current saved state for this thread. | |
| 140 HAL_SavedRegisters *get_saved_context(); | |
| 141 | |
| 142 // Set the saved context pointer. | |
| 143 void set_saved_context(HAL_SavedRegisters *ctx); | |
| 144 #endif | |
| 145 | |
| 146 // get the size/base of this thread's stack | |
| 147 CYG_ADDRESS get_stack_base(); | |
| 148 | |
| 149 cyg_uint32 get_stack_size(); | |
| 150 | |
| 151 #ifdef CYGFUN_KERNEL_THREADS_STACK_LIMIT | |
| 152 // Allocate some memory at the lower end of the stack | |
| 153 // by moving the stack limit pointer. | |
| 154 | |
| 155 void *increment_stack_limit( cyg_ucount32 size); | |
| 156 | |
| 157 CYG_ADDRESS get_stack_limit(); | |
| 158 #endif | |
|
143
6b5f480c6929
Merge from eCos master repository on 2000-12-08-02:09:36-GMT
jlarmour
parents:
66
diff
changeset
|
159 |
|
6b5f480c6929
Merge from eCos master repository on 2000-12-08-02:09:36-GMT
jlarmour
parents:
66
diff
changeset
|
160 #ifdef CYGFUN_KERNEL_THREADS_STACK_CHECKING |
|
6b5f480c6929
Merge from eCos master repository on 2000-12-08-02:09:36-GMT
jlarmour
parents:
66
diff
changeset
|
161 |
|
6b5f480c6929
Merge from eCos master repository on 2000-12-08-02:09:36-GMT
jlarmour
parents:
66
diff
changeset
|
162 inline void check_stack(void); |
|
6b5f480c6929
Merge from eCos master repository on 2000-12-08-02:09:36-GMT
jlarmour
parents:
66
diff
changeset
|
163 |
|
6b5f480c6929
Merge from eCos master repository on 2000-12-08-02:09:36-GMT
jlarmour
parents:
66
diff
changeset
|
164 #endif |
| 0 | 165 }; |
| 166 | |
| 167 // ------------------------------------------------------------------------- | |
| 168 // Per-thread timer support class. | |
| 169 // This is only included when required. | |
| 170 | |
| 171 #ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 172 | |
| 173 class Cyg_ThreadTimer | |
| 174 : public Cyg_Alarm | |
| 175 { | |
| 176 friend class Cyg_Thread; | |
| 177 | |
| 178 // Pointer to current thread | |
| 179 Cyg_Thread *thread; | |
| 180 | |
| 181 // Constructor | |
| 182 Cyg_ThreadTimer( | |
| 183 Cyg_Thread *thread | |
| 184 ); | |
| 185 | |
| 186 // Alarm function | |
| 187 static void alarm( Cyg_Alarm *alarm, CYG_ADDRWORD data); | |
| 188 | |
| 189 CYGDBG_DEFINE_CHECK_THIS | |
| 190 | |
| 191 }; | |
| 192 | |
| 193 #endif | |
| 194 | |
| 195 // ------------------------------------------------------------------------- | |
| 196 // Main Thread class. | |
| 197 // This provides the public API for controlling threads. | |
| 198 | |
| 199 class Cyg_Thread | |
| 200 : public Cyg_HardwareThread, // provides hardware abstractions | |
| 201 public Cyg_SchedThread // provides scheduling abstractions | |
| 202 { | |
| 203 friend class Cyg_Scheduler; | |
| 204 friend void deliver_exception( CYG_WORD code, CYG_ADDRWORD data ); | |
| 205 | |
| 206 // The following definitions are used by all variants of the | |
| 207 // basic thread object. | |
| 208 | |
| 209 public: | |
| 210 enum { // Thread state values | |
| 211 | |
| 212 RUNNING = 0, // Thread is runnable or running | |
| 213 SLEEPING = 1, // Thread is waiting for something to happen | |
| 2 | 214 COUNTSLEEP = 2, // Sleep in counted manner |
| 0 | 215 SUSPENDED = 4, // Suspend count is non-zero |
| 216 CREATING = 8, // Thread is being created | |
| 217 EXITED = 16, // Thread has exited | |
| 218 | |
| 219 // This is the set of bits that must be cleared by a generic | |
| 220 // wake() or release(). | |
| 221 SLEEPSET = (SLEEPING | COUNTSLEEP) | |
| 222 }; | |
| 223 | |
| 224 private: | |
| 225 // Current thread state, a logical OR of the above values. | |
| 226 // Only if this word is zero can the thread execute. | |
| 227 cyg_uint32 state; | |
| 228 | |
| 229 // Suspension counter, if > 0, the thread is suspended | |
| 230 cyg_ucount32 suspend_count; | |
| 231 | |
| 232 // Wakeup counter, if > 0, sleep will not sleep, just decrement | |
| 233 cyg_ucount32 wakeup_count; | |
| 234 | |
| 235 // A word of data used in syncronization object to communicate | |
| 236 // information between sleepers and wakers. | |
| 237 CYG_ADDRWORD wait_info; | |
| 238 | |
| 239 // Unique thread id assigned on creation | |
| 240 cyg_uint16 unique_id; | |
| 241 | |
| 242 #ifdef CYGPKG_KERNEL_EXCEPTIONS | |
| 243 | |
| 244 // If exceptions are supported, define an exception control | |
| 245 // object that will be used to manage and deliver them. If | |
| 246 // exceptions are global there is a single static instance | |
| 247 // of this object, if they are per-thread then there is one | |
| 248 // for each thread. | |
| 249 private: | |
| 250 | |
| 251 #ifdef CYGSEM_KERNEL_EXCEPTIONS_GLOBAL | |
| 252 static | |
| 253 #endif | |
| 254 Cyg_Exception_Control exception_control; | |
| 255 | |
| 256 public: | |
| 257 | |
| 258 static void register_exception( | |
| 259 cyg_code exception_number, // exception number | |
| 260 cyg_exception_handler handler, // handler function | |
| 261 CYG_ADDRWORD data, // data argument | |
| 262 cyg_exception_handler **old_handler, // handler function | |
| 263 CYG_ADDRWORD *old_data // data argument | |
| 264 ); | |
| 265 | |
| 266 static void deregister_exception( | |
| 267 cyg_code exception_number // exception number | |
| 268 ); | |
| 269 | |
| 270 void deliver_exception( | |
| 271 cyg_code exception_number, // exception being raised | |
| 272 CYG_ADDRWORD exception_info // exception specific info | |
| 273 ); | |
| 274 | |
| 275 #endif | |
| 276 | |
| 277 | |
| 278 public: | |
| 279 | |
| 280 CYGDBG_DEFINE_CHECK_THIS | |
| 281 | |
| 282 // Constructor, Initialize the thread structure. The thread is | |
| 283 // created in suspended state, and needs to be resumed to execute. | |
| 284 // It is also started at some (configurable) default priority, which | |
| 285 // may need to be changed before calling resume. | |
| 286 | |
| 287 Cyg_Thread ( | |
| 288 cyg_thread_entry *entry, // entry point function | |
| 289 CYG_ADDRWORD entry_data, // entry data | |
| 290 cyg_ucount32 stack_size = 0, // stack size, 0 = use default | |
| 291 CYG_ADDRESS stack_base = 0 // stack base, NULL = allocate | |
| 292 ); | |
| 293 | |
| 294 Cyg_Thread ( | |
| 295 CYG_ADDRWORD sched_info, // Scheduling parameter(s) | |
| 296 cyg_thread_entry *entry, // entry point function | |
| 297 CYG_ADDRWORD entry_data, // entry data | |
| 298 char *name, // thread name | |
| 299 CYG_ADDRESS stack_base = 0, // stack base, NULL = allocate | |
| 300 cyg_ucount32 stack_size = 0 // stack size, 0 = use default | |
| 301 ); | |
| 302 | |
| 303 // Re-initialize the thread back to it's initial state. | |
| 304 void Cyg_Thread::reinitialize(); | |
| 305 | |
| 306 ~Cyg_Thread(); | |
| 307 | |
| 308 // The following are invoked implicitly on the current thread, | |
| 309 // hence they are static member functions. | |
| 310 | |
| 311 static void sleep(); // Put thread to sleep | |
| 312 | |
| 313 static void counted_sleep();// Decrement counter or put | |
| 314 // thread to sleep | |
| 315 #ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 316 static void counted_sleep( cyg_tick_count delay ); | |
| 317 // ...for delay ticks | |
| 318 #endif | |
| 319 | |
| 320 static void exit(); // Terminate thread | |
| 321 | |
| 322 static void yield(); // Yield CPU to another thread | |
| 323 | |
| 2 | 324 static void rotate_queue( cyg_priority pri ); |
| 0 | 325 // Rotate that run queue |
| 2 | 326 |
| 327 void to_queue_head( void ); | |
| 328 // Move to the head of its queue | |
| 329 // (not necessarily a scheduler q) | |
| 0 | 330 |
| 331 static Cyg_Thread *self(); // Return current thread | |
| 332 | |
| 333 | |
| 334 // The following are called on threads other than the current one. | |
| 335 | |
| 336 void wake(); // Wake this thread from sleep. | |
| 337 | |
| 338 void counted_wake(); // Increment counter or wake thread | |
| 339 cyg_uint32 cancel_counted_wake(); | |
| 340 // Cancel counted wakeups for this | |
| 341 // thread and return how many were | |
| 342 // pending | |
| 343 | |
| 344 void suspend(); // Suspend this thread: increment counter and | |
| 345 // deschedule. | |
| 346 | |
| 347 void resume(); // Resume this thread: decrement counter and | |
| 348 // reschedule if counter is zero. | |
| 349 | |
| 350 void release(); // Release thread from sleep with BREAK | |
| 351 // wake_reason. | |
| 352 | |
| 353 void kill(); // Kill this thread | |
| 354 | |
| 355 void force_resume(); // Resume this thread: set counter to zero. | |
| 356 | |
| 357 cyg_uint32 get_state(); // Return current thread state. | |
| 358 | |
| 359 | |
| 360 // Accessor functions to set and get wait_info. | |
| 361 | |
| 362 void set_wait_info(CYG_ADDRWORD data); | |
| 363 | |
| 364 CYG_ADDRWORD get_wait_info(); | |
| 365 | |
| 366 // This part of the API is used if we have a clock and want | |
| 367 // per-thread timers for doing delays and timeouts. | |
| 368 | |
| 369 // delay the given number of ticks | |
| 370 void delay( cyg_tick_count delay ); | |
| 371 | |
| 372 | |
| 373 enum cyg_reason // sleep/wakeup reason codes | |
| 374 { | |
| 375 NONE, // No recorded reason | |
| 376 WAIT, // Wait with no timeout | |
| 377 DELAY, // Simple time delay | |
| 378 TIMEOUT, // Wait with timeout/timeout expired | |
| 379 BREAK, // forced break out of sleep | |
| 380 DESTRUCT, // wait object destroyed[note] | |
| 381 EXIT, // forced termination | |
| 382 DONE // Wait/delay complete | |
| 383 }; | |
| 384 // [note] NOT the thread, some object it was waiting on. | |
| 385 // Thread destruction would first involve EXITing it. | |
| 386 | |
| 387 private: | |
| 388 | |
| 389 #ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 390 Cyg_ThreadTimer timer; // per-thread timer | |
| 391 #endif | |
| 392 | |
| 393 cyg_reason sleep_reason; // reason for sleeping | |
| 394 | |
| 395 cyg_reason wake_reason; // reason for waking | |
| 396 | |
| 397 #ifdef CYGIMP_THREAD_PRIORITY | |
| 398 | |
| 399 public: | |
| 400 | |
| 401 // If the scheduler implements priorities, provide | |
| 402 // functions to set and get it. | |
| 403 | |
| 404 void set_priority( cyg_priority pri ); | |
| 405 | |
| 406 cyg_priority get_priority(); | |
| 407 | |
| 408 // This returns the current dispatching priority of the | |
| 409 // thread. This may differ from the result of get_priority() | |
| 410 // in the presence of priority inheritance or certain | |
| 411 // scheduling algorithms. | |
| 412 cyg_priority get_current_priority(); | |
| 413 | |
| 414 #endif | |
| 415 | |
| 416 #ifdef CYGVAR_KERNEL_THREADS_DATA | |
| 417 | |
| 418 private: | |
| 419 // Array of single word entries for each index. | |
| 420 CYG_ADDRWORD thread_data[CYGNUM_KERNEL_THREADS_DATA_MAX]; | |
| 421 | |
| 422 // Map of free thread_data indexes. Each bit represents an index | |
| 423 // and is 1 if that index is free, and 0 if it is in use. | |
| 424 static cyg_ucount32 thread_data_map; | |
| 425 | |
| 426 public: | |
| 427 | |
| 428 static CYG_ADDRWORD get_data( cyg_ucount32 index ); | |
| 429 | |
| 430 static CYG_ADDRWORD *get_data_ptr( cyg_ucount32 index ); | |
| 431 | |
| 432 void set_data( cyg_ucount32 index, CYG_ADDRWORD data ); | |
| 433 | |
| 434 static cyg_ucount32 new_data_index(); | |
| 435 | |
| 436 static void free_data_index( cyg_ucount32 index ); | |
| 437 | |
| 438 #endif | |
| 439 | |
| 440 #ifdef CYGVAR_KERNEL_THREADS_NAME | |
| 441 | |
| 442 private: | |
| 443 // An optional thread name string, for humans to read | |
| 444 char *name; | |
| 445 | |
| 446 public: | |
| 447 // function to get the name string | |
| 448 char *get_name(); | |
| 449 | |
| 450 #endif | |
| 451 | |
| 452 | |
| 453 #ifdef CYGVAR_KERNEL_THREADS_LIST | |
| 454 | |
| 455 // Housekeeping list that tracks all threads | |
| 456 private: | |
| 457 Cyg_Thread *list_next; | |
| 458 static Cyg_Thread *thread_list; | |
| 459 | |
| 460 void add_to_list( void ); | |
| 461 void remove_from_list( void ); | |
| 462 public: | |
| 463 | |
| 464 static Cyg_Thread *get_list_head(); | |
| 465 | |
| 466 Cyg_Thread *get_list_next(); | |
| 467 | |
| 468 #endif | |
| 469 | |
| 470 public: | |
| 471 | |
| 472 // Set sleep reason to reason and wake reason to NONE | |
| 473 static void set_sleep_reason( cyg_reason reason = WAIT); | |
| 474 | |
| 475 cyg_reason get_sleep_reason(); | |
| 476 | |
| 477 // Set the wakeup reason to the given value | |
| 478 void set_wake_reason( cyg_reason reason = DONE); | |
| 479 | |
| 480 // Get current wake reason | |
| 481 cyg_reason get_wake_reason(); | |
| 482 | |
| 483 static void set_timer( // Set timeout and sleep reason | |
| 484 cyg_tick_count trigger, // Absolute wakeup time | |
| 485 cyg_reason sleep_reason // reason for sleeping | |
| 486 ); | |
| 487 | |
| 488 static void clear_timer(); // disable thread timer | |
| 489 | |
| 490 // Get a 16 bit unique id for this thread. This is | |
| 491 // used in tracing and instrumentation to identify the | |
| 492 // current thread. | |
| 493 | |
| 494 cyg_uint16 get_unique_id(); | |
| 495 | |
| 496 }; | |
| 497 | |
| 498 // ------------------------------------------------------------------------- | |
| 499 // Thread Queue class. | |
| 500 // This defines the main API for manipulating queues of threads. | |
| 501 | |
| 502 class Cyg_ThreadQueue | |
| 2 | 503 : public Cyg_ThreadQueue_Implementation |
| 0 | 504 { |
| 505 | |
| 506 public: | |
| 507 | |
| 508 CYGDBG_DEFINE_CHECK_THIS | |
| 509 | |
| 510 // API used by rest of kernel. | |
| 511 | |
| 512 // Add thread to queue | |
| 513 void enqueue(Cyg_Thread *thread); | |
| 514 | |
| 515 // return first thread on queue | |
| 516 Cyg_Thread *highpri(); | |
| 517 | |
| 518 // remove first thread on queue | |
| 519 Cyg_Thread *dequeue(); | |
| 520 | |
| 521 // remove specified thread from queue | |
| 522 void remove(Cyg_Thread *thread); | |
| 523 | |
| 524 // test if queue is empty | |
| 525 cyg_bool empty(); | |
| 526 | |
| 527 }; | |
| 528 | |
| 529 // ------------------------------------------------------------------------- | |
| 530 // Thread inlines | |
| 531 | |
| 532 // Return current thread state. | |
| 533 inline cyg_uint32 Cyg_Thread::get_state() | |
| 534 { | |
| 535 return state; | |
| 536 } | |
| 537 | |
| 538 inline void Cyg_Thread::set_wait_info(CYG_ADDRWORD data) | |
| 539 { | |
| 540 wait_info = data; | |
| 541 } | |
| 542 | |
| 543 inline CYG_ADDRWORD Cyg_Thread::get_wait_info() | |
| 544 { | |
| 545 return wait_info; | |
| 546 } | |
| 547 | |
| 548 // ------------------------------------------------------------------------- | |
| 549 #endif // ifndef CYGONCE_KERNEL_THREAD_HXX | |
| 550 // EOF thread.hxx |
