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

Function sleepq_set_timeout_sbt

freebsd/kern/subr_sleepqueue.c:394–418  ·  view source on GitHub ↗

* Sets a timeout that will remove the current thread from the specified * sleep queue after timo ticks if the thread has not already been awakened. */

Source from the content-addressed store, hash-verified

392 * sleep queue after timo ticks if the thread has not already been awakened.
393 */
394void
395sleepq_set_timeout_sbt(const void *wchan, sbintime_t sbt, sbintime_t pr,
396 int flags)
397{
398 struct sleepqueue_chain *sc __unused;
399 struct thread *td;
400 sbintime_t pr1;
401
402 td = curthread;
403 sc = SC_LOOKUP(wchan);
404 mtx_assert(&sc->sc_lock, MA_OWNED);
405 MPASS(TD_ON_SLEEPQ(td));
406 MPASS(td->td_sleepqueue == NULL);
407 MPASS(wchan != NULL);
408 if (cold && td == &thread0)
409 panic("timed sleep before timers are working");
410 KASSERT(td->td_sleeptimo == 0, ("td %d %p td_sleeptimo %jx",
411 td->td_tid, td, (uintmax_t)td->td_sleeptimo));
412 thread_lock(td);
413 callout_when(sbt, pr, flags, &td->td_sleeptimo, &pr1);
414 thread_unlock(td);
415 callout_reset_sbt_on(&td->td_slpcallout, td->td_sleeptimo, pr1,
416 sleepq_timeout, td, PCPU_GET(cpuid), flags | C_PRECALC |
417 C_DIRECT_EXEC);
418}
419
420/*
421 * Return the number of actual sleepers for the specified queue.

Callers 4

_cv_timedwait_sbtFunction · 0.85
_cv_timedwait_sig_sbtFunction · 0.85
_sleepFunction · 0.85
msleep_spin_sbtFunction · 0.85

Calls 4

mtx_assertFunction · 0.85
callout_whenFunction · 0.85
callout_reset_sbt_onFunction · 0.85
panicFunction · 0.70

Tested by

no test coverage detected