MCPcopy Create free account
hub / github.com/HelenOS/helenos / thread_destroy

Function thread_destroy

kernel/generic/src/proc/thread.c:430–459  ·  view source on GitHub ↗

Destroy thread memory structure * * Detach thread from all queues, cpus etc. and destroy it. * * @param thread Thread to be destroyed. * @param irq_res Indicate whether it should unlock thread->lock * in interrupts-restore mode. * */

Source from the content-addressed store, hash-verified

428 *
429 */
430void thread_destroy(thread_t *thread, bool irq_res)
431{
432 assert(irq_spinlock_locked(&thread->lock));
433 assert((thread->state == Exiting) || (thread->state == Lingering));
434 assert(thread->task);
435 assert(thread->cpu);
436
437 irq_spinlock_lock(&thread->cpu->lock, false);
438 if (thread->cpu->fpu_owner == thread)
439 thread->cpu->fpu_owner = NULL;
440 irq_spinlock_unlock(&thread->cpu->lock, false);
441
442 irq_spinlock_pass(&thread->lock, &threads_lock);
443
444 odict_remove(&thread->lthreads);
445
446 irq_spinlock_pass(&threads_lock, &thread->task->lock);
447
448 /*
449 * Detach from the containing task.
450 */
451 list_remove(&thread->th_link);
452 irq_spinlock_unlock(&thread->task->lock, irq_res);
453
454 /*
455 * Drop the reference to the containing task.
456 */
457 task_release(thread->task);
458 slab_free(thread_cache, thread);
459}
460
461/** Make the thread visible to the system.
462 *

Callers 2

thread_detachFunction · 0.85

Calls 8

irq_spinlock_lockedFunction · 0.85
irq_spinlock_lockFunction · 0.85
irq_spinlock_unlockFunction · 0.85
irq_spinlock_passFunction · 0.85
task_releaseFunction · 0.85
slab_freeFunction · 0.85
odict_removeFunction · 0.50
list_removeFunction · 0.50

Tested by

no test coverage detected