| 332 | } |
| 333 | |
| 334 | void |
| 335 | kthread_exit(void) |
| 336 | { |
| 337 | struct proc *p; |
| 338 | struct thread *td; |
| 339 | |
| 340 | td = curthread; |
| 341 | p = td->td_proc; |
| 342 | |
| 343 | #ifdef HWPMC_HOOKS |
| 344 | if (PMC_SYSTEM_SAMPLING_ACTIVE()) |
| 345 | PMC_CALL_HOOK_UNLOCKED(td, PMC_FN_THR_EXIT_LOG, NULL); |
| 346 | #endif |
| 347 | /* A module may be waiting for us to exit. */ |
| 348 | wakeup(td); |
| 349 | |
| 350 | /* |
| 351 | * The last exiting thread in a kernel process must tear down |
| 352 | * the whole process. |
| 353 | */ |
| 354 | PROC_LOCK(p); |
| 355 | if (p->p_numthreads == 1) { |
| 356 | PROC_UNLOCK(p); |
| 357 | kproc_exit(0); |
| 358 | } |
| 359 | |
| 360 | if (p->p_sysent->sv_ontdexit != NULL) |
| 361 | p->p_sysent->sv_ontdexit(td); |
| 362 | |
| 363 | tidhash_remove(td); |
| 364 | umtx_thread_exit(td); |
| 365 | tdsigcleanup(td); |
| 366 | PROC_SLOCK(p); |
| 367 | thread_exit(); |
| 368 | } |
| 369 | |
| 370 | /* |
| 371 | * Advise a kernel process to suspend (or resume) in its main loop. |
no test coverage detected