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

Function kthread_suspend_check

freebsd/kern/kern_kthread.c:433–459  ·  view source on GitHub ↗

* Used by the thread to poll as to whether it should yield/sleep * and notify the caller that is has happened. */

Source from the content-addressed store, hash-verified

431 * and notify the caller that is has happened.
432 */
433void
434kthread_suspend_check(void)
435{
436 struct proc *p;
437 struct thread *td;
438
439 td = curthread;
440 p = td->td_proc;
441
442 if ((td->td_pflags & TDP_KTHREAD) == 0)
443 panic("%s: curthread is not a valid kthread", __func__);
444
445 /*
446 * Setting the TDF_KTH_SUSP flag is protected by process lock.
447 *
448 * Do an unlocked read first to avoid serializing with all other threads
449 * in the common case of not suspending.
450 */
451 if ((td->td_flags & TDF_KTH_SUSP) == 0)
452 return;
453 PROC_LOCK(p);
454 while ((td->td_flags & TDF_KTH_SUSP) != 0) {
455 wakeup(&td->td_flags);
456 msleep(&td->td_flags, &p->p_mtx, PPAUSE, "ktsusp", 0);
457 }
458 PROC_UNLOCK(p);
459}
460
461int
462kproc_kthread_add(void (*func)(void *), void *arg,

Callers 2

bufspace_daemonFunction · 0.85
buf_daemonFunction · 0.85

Calls 2

panicFunction · 0.70
wakeupFunction · 0.70

Tested by

no test coverage detected