Changeset 58775d30 in mainline for kernel/generic/src/proc/thread.c
- Timestamp:
- 2015-03-16T16:07:21Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2003739
- Parents:
- 6069061 (diff), 795e2bf (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/proc/thread.c
r6069061 r58775d30 46 46 #include <synch/spinlock.h> 47 47 #include <synch/waitq.h> 48 #include <synch/workqueue.h> 49 #include <synch/rcu.h> 48 50 #include <cpu.h> 49 51 #include <str.h> … … 263 265 } 264 266 267 /** Invoked right before thread_ready() readies the thread. thread is locked. */ 268 static void before_thread_is_ready(thread_t *thread) 269 { 270 ASSERT(irq_spinlock_locked(&thread->lock)); 271 workq_before_thread_is_ready(thread); 272 } 273 265 274 /** Make thread ready 266 275 * … … 275 284 276 285 ASSERT(thread->state != Ready); 286 287 before_thread_is_ready(thread); 277 288 278 289 int i = (thread->priority < RQ_COUNT - 1) ? 279 290 ++thread->priority : thread->priority; 280 281 cpu_t *cpu; 282 if (thread->wired || thread->nomigrate || thread->fpu_context_engaged) { 283 ASSERT(thread->cpu != NULL); 284 cpu = thread->cpu; 285 } else 291 292 /* Check that thread->cpu is set whenever it needs to be. */ 293 ASSERT(thread->cpu != NULL || 294 (!thread->wired && !thread->nomigrate && !thread->fpu_context_engaged)); 295 296 /* 297 * Prefer to run on the same cpu as the last time. Used by wired 298 * threads as well as threads with disabled migration. 299 */ 300 cpu_t *cpu = thread->cpu; 301 if (cpu == NULL) 286 302 cpu = CPU; 287 303 … … 377 393 thread->task = task; 378 394 395 thread->workq = NULL; 396 379 397 thread->fpu_context_exists = false; 380 398 thread->fpu_context_engaged = false; … … 391 409 /* Might depend on previous initialization */ 392 410 thread_create_arch(thread); 411 412 rcu_thread_init(thread); 393 413 394 414 if ((flags & THREAD_FLAG_NOATTACH) != THREAD_FLAG_NOATTACH) … … 501 521 */ 502 522 ipc_cleanup(); 503 futex_ cleanup();523 futex_task_cleanup(); 504 524 LOG("Cleanup of task %" PRIu64" completed.", TASK->taskid); 505 525 } … … 521 541 /* Not reached */ 522 542 while (true); 543 } 544 545 /** Interrupts an existing thread so that it may exit as soon as possible. 546 * 547 * Threads that are blocked waiting for a synchronization primitive 548 * are woken up with a return code of ESYNCH_INTERRUPTED if the 549 * blocking call was interruptable. See waitq_sleep_timeout(). 550 * 551 * The caller must guarantee the thread object is valid during the entire 552 * function, eg by holding the threads_lock lock. 553 * 554 * Interrupted threads automatically exit when returning back to user space. 555 * 556 * @param thread A valid thread object. The caller must guarantee it 557 * will remain valid until thread_interrupt() exits. 558 */ 559 void thread_interrupt(thread_t *thread) 560 { 561 ASSERT(thread != NULL); 562 563 irq_spinlock_lock(&thread->lock, true); 564 565 thread->interrupted = true; 566 bool sleeping = (thread->state == Sleeping); 567 568 irq_spinlock_unlock(&thread->lock, true); 569 570 if (sleeping) 571 waitq_interrupt_sleep(thread); 572 } 573 574 /** Returns true if the thread was interrupted. 575 * 576 * @param thread A valid thread object. User must guarantee it will 577 * be alive during the entire call. 578 * @return true if the thread was already interrupted via thread_interrupt(). 579 */ 580 bool thread_interrupted(thread_t *thread) 581 { 582 ASSERT(thread != NULL); 583 584 bool interrupted; 585 586 irq_spinlock_lock(&thread->lock, true); 587 interrupted = thread->interrupted; 588 irq_spinlock_unlock(&thread->lock, true); 589 590 return interrupted; 523 591 } 524 592
Note:
See TracChangeset
for help on using the changeset viewer.