Make the thread visible to the system. * * Attach the thread structure to the current task and make it visible in the * threads_tree. * * @param t Thread to be attached to the task. * @param task Task to which the thread is to be attached. * */
| 468 | * |
| 469 | */ |
| 470 | void thread_attach(thread_t *thread, task_t *task) |
| 471 | { |
| 472 | /* |
| 473 | * Attach to the specified task. |
| 474 | */ |
| 475 | irq_spinlock_lock(&task->lock, true); |
| 476 | |
| 477 | /* Hold a reference to the task. */ |
| 478 | task_hold(task); |
| 479 | |
| 480 | /* Must not count kbox thread into lifecount */ |
| 481 | if (thread->uspace) |
| 482 | atomic_inc(&task->lifecount); |
| 483 | |
| 484 | list_append(&thread->th_link, &task->threads); |
| 485 | |
| 486 | irq_spinlock_pass(&task->lock, &threads_lock); |
| 487 | |
| 488 | /* |
| 489 | * Register this thread in the system-wide dictionary. |
| 490 | */ |
| 491 | odict_insert(&thread->lthreads, &threads, NULL); |
| 492 | irq_spinlock_unlock(&threads_lock, true); |
| 493 | } |
| 494 | |
| 495 | /** Terminate thread. |
| 496 | * |
no test coverage detected