* Reclaim a thread after use. */
| 371 | * Reclaim a thread after use. |
| 372 | */ |
| 373 | static void |
| 374 | thread_dtor(void *mem, int size, void *arg) |
| 375 | { |
| 376 | struct thread *td; |
| 377 | |
| 378 | td = (struct thread *)mem; |
| 379 | |
| 380 | #ifdef INVARIANTS |
| 381 | /* Verify that this thread is in a safe state to free. */ |
| 382 | switch (td->td_state) { |
| 383 | case TDS_INHIBITED: |
| 384 | case TDS_RUNNING: |
| 385 | case TDS_CAN_RUN: |
| 386 | case TDS_RUNQ: |
| 387 | /* |
| 388 | * We must never unlink a thread that is in one of |
| 389 | * these states, because it is currently active. |
| 390 | */ |
| 391 | panic("bad state for thread unlinking"); |
| 392 | /* NOTREACHED */ |
| 393 | case TDS_INACTIVE: |
| 394 | break; |
| 395 | default: |
| 396 | panic("bad thread state"); |
| 397 | /* NOTREACHED */ |
| 398 | } |
| 399 | #endif |
| 400 | #ifdef AUDIT |
| 401 | audit_thread_free(td); |
| 402 | #endif |
| 403 | #ifdef KDTRACE_HOOKS |
| 404 | kdtrace_thread_dtor(td); |
| 405 | #endif |
| 406 | /* Free all OSD associated to this thread. */ |
| 407 | osd_thread_exit(td); |
| 408 | td_softdep_cleanup(td); |
| 409 | MPASS(td->td_su == NULL); |
| 410 | seltdfini(td); |
| 411 | } |
| 412 | |
| 413 | /* |
| 414 | * Initialize type-stable parts of a thread (when newly created). |
nothing calls this directly
no test coverage detected