* 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. */
| 309 | * zero is equivalent to a "sbt" value of one tick. |
| 310 | */ |
| 311 | int |
| 312 | pause_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. |
no test coverage detected