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

Function pause_sbt

freebsd/kern/kern_synch.c:311–338  ·  view source on GitHub ↗

* pause_sbt() delays the calling thread by the given signed binary * time. During cold bootup, pause_sbt() uses the DELAY() function * instead of the _sleep() function to do the waiting. The "sbt" * argument must be greater than or equal to zero. A "sbt" value of * zero is equivalent to a "sbt" value of one tick. */

Source from the content-addressed store, hash-verified

309 * zero is equivalent to a "sbt" value of one tick.
310 */
311int
312pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags)
313{
314 KASSERT(sbt >= 0, ("pause_sbt: timeout must be >= 0"));
315
316 /* silently convert invalid timeouts */
317 if (sbt == 0)
318 sbt = tick_sbt;
319
320 if ((cold && curthread == &thread0) || kdb_active ||
321 SCHEDULER_STOPPED()) {
322 /*
323 * We delay one second at a time to avoid overflowing the
324 * system specific DELAY() function(s):
325 */
326 while (sbt >= SBT_1S) {
327 DELAY(1000000);
328 sbt -= SBT_1S;
329 }
330 /* Do the delay remainder, if any */
331 sbt = howmany(sbt, SBT_1US);
332 if (sbt > 0)
333 DELAY(sbt);
334 return (EWOULDBLOCK);
335 }
336 return (_sleep(&pause_wchan[curcpu], NULL,
337 (flags & C_CATCH) ? PCATCH : 0, wmesg, sbt, pr, flags));
338}
339
340/*
341 * Make all threads sleeping on the specified identifier runnable.

Callers 1

wait_for_xferFunction · 0.50

Calls 2

_sleepFunction · 0.70
DELAYFunction · 0.50

Tested by

no test coverage detected