FreeBSD/sys/kern/kern_kthread.c
/*
 * Used by the thread to poll as to whether it should yield/sleep
 * and notify the caller that is has happened.
 */
Used by the thread to poll as to whether it should yield/sleep
and notify the caller that is has happened.
Used by the thread to poll as to whether it should yield / sleep and notify the caller that is has happened .
void
kthread_suspend_check(void)
{
	struct proc *p;
	struct thread *td;
	td = curthread;
	p = td->td_proc;
	if ((td->td_pflags & TDP_KTHREAD) == 0)
		panic("%s: curthread is not a valid kthread", __func__);
	PROC_LOCK(p);
	while (td->td_flags & TDF_KTH_SUSP) {
		wakeup(&td->td_flags);
		msleep(&td->td_flags, &p->p_mtx, PPAUSE, "ktsusp", 0);
	}
	PROC_UNLOCK(p);
}
void kthread_suspend_check ( void ) { struct proc * p ; struct thread * td ; td = curthread ; p = td -> td_proc ; if ( ( td -> td_pflags & TDP_KTHREAD ) == 0 ) panic ( " " , __func__ ) ; PROC_LOCK ( p ) ; while ( td -> td_flags & TDF_KTH_SUSP ) { wakeup ( & td -> td_flags ) ; msleep ( & td -> td_flags , & p -> p_mtx , PPAUSE , " " , 0 ) ; } PROC_UNLOCK ( p ) ; }
Used by the thread to poll as to whether it should yield/sleep
 and notify the caller that is has happened.
Used by the thread to poll as to whether it should yield / sleep and notify the caller that is has happened .
/*
	 * As long as the double-lock protection is used when accessing the
	 * TDF_KTH_SUSP flag, synchronizing the read operation via proc mutex
	 * is fine.
	 */