MCPcopy Create free account
hub / github.com/F-Stack/f-stack / thread_dtor

Function thread_dtor

freebsd/kern/kern_thread.c:373–411  ·  view source on GitHub ↗

* Reclaim a thread after use. */

Source from the content-addressed store, hash-verified

371 * Reclaim a thread after use.
372 */
373static void
374thread_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).

Callers

nothing calls this directly

Calls 5

audit_thread_freeFunction · 0.85
kdtrace_thread_dtorFunction · 0.85
td_softdep_cleanupFunction · 0.85
seltdfiniFunction · 0.85
panicFunction · 0.70

Tested by

no test coverage detected