Changeset 518dd43 in mainline
- Timestamp:
- 2012-07-06T13:06:44Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8a64e81e
- Parents:
- 46a5b37
- Location:
- kernel/generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/proc/thread.h
r46a5b37 r518dd43 217 217 extern void thread_ready(thread_t *); 218 218 extern void thread_exit(void) __attribute__((noreturn)); 219 extern void thread_interrupt(thread_t *); 220 extern bool thread_interrupted(thread_t *); 219 221 220 222 #ifndef thread_create_arch -
kernel/generic/src/proc/thread.c
r46a5b37 r518dd43 272 272 273 273 ASSERT(thread->state != Ready); 274 274 275 275 int i = (thread->priority < RQ_COUNT - 1) ? 276 276 ++thread->priority : thread->priority; 277 278 cpu_t *cpu; 279 if (thread->wired || thread->nomigrate || thread->fpu_context_engaged) { 280 ASSERT(thread->cpu != NULL); 281 cpu = thread->cpu; 282 } else 277 278 /* Check that thread->cpu is set whenever it needs to be. */ 279 ASSERT(thread->cpu != NULL || 280 (!thread->wired && !thread->nomigrate && !thread->fpu_context_engaged)); 281 282 /* 283 * Prefer to run on the same cpu as the last time. Used by wired 284 * threads as well as threads with disabled migration. 285 */ 286 cpu_t *cpu = thread->cpu; 287 if (cpu == NULL) 283 288 cpu = CPU; 284 289 … … 518 523 /* Not reached */ 519 524 while (true); 525 } 526 527 /** Interrupts an existing thread so that it may exit as soon as possible. 528 * 529 * Threads that are blocked waiting for a synchronization primitive 530 * are woken up with a return code of ESYNCH_INTERRUPTED if the 531 * blocking call was interruptable. See waitq_sleep_timeout(). 532 * 533 * The caller must guarantee the thread object is valid during the entire 534 * function, eg by holding the threads_lock lock. 535 * 536 * Interrupted threads automatically exit when returning back to user space. 537 * 538 * @param thread A valid thread object. The caller must guarantee it 539 * will remain valid until thread_interrupt() exits. 540 */ 541 void thread_interrupt(thread_t *thread) 542 { 543 ASSERT(thread != NULL); 544 545 irq_spinlock_lock(&thread->lock, true); 546 547 thread->interrupted = true; 548 bool sleeping = (thread->state == Sleeping); 549 550 irq_spinlock_unlock(&thread->lock, true); 551 552 if (sleeping) 553 waitq_interrupt_sleep(thread); 554 } 555 556 /** Returns true if the thread was interrupted. 557 * 558 * @param thread A valid thread object. User must guarantee it will 559 * be alive during the entire call. 560 * @return true if the thread was already interrupted via thread_interrupt(). 561 */ 562 bool thread_interrupted(thread_t *thread) 563 { 564 ASSERT(thread != NULL); 565 566 bool interrupted; 567 568 irq_spinlock_lock(&thread->lock, true); 569 interrupted = thread->interrupted; 570 irq_spinlock_unlock(&thread->lock, true); 571 572 return interrupted; 520 573 } 521 574
Note:
See TracChangeset
for help on using the changeset viewer.