FreeBSD/sys/kern/kern_kthread.c
/*
 * Advise a kernel process to suspend (or resume) in its main loop.
 * Participation is voluntary.
 */
Advise a kernel process to suspend (or resume) in its main loop.
Participation is voluntary.
Advise a kernel process to suspend ( or resume ) in its main loop . Participation is voluntary .
int
kthread_suspend(struct thread *td, int timo)
{
	struct proc *p;
	p = td->td_proc;
	if ((td->td_pflags & TDP_KTHREAD) == 0)
		return (EINVAL);
	PROC_LOCK(p);
	thread_lock(td);
	td->td_flags |= TDF_KTH_SUSP;
	thread_unlock(td);
	return (msleep(&td->td_flags, &p->p_mtx, PPAUSE | PDROP, "suspkt",
	    timo));
}
int kthread_suspend ( struct thread * td , int timo ) { struct proc * p ; p = td -> td_proc ; if ( ( td -> td_pflags & TDP_KTHREAD ) == 0 ) return ( EINVAL ) ; PROC_LOCK ( p ) ; thread_lock ( td ) ; td -> td_flags |= TDF_KTH_SUSP ; thread_unlock ( td ) ; return ( msleep ( & td -> td_flags , & p -> p_mtx , PPAUSE | PDROP , " " , timo ) ) ; }
Advise a kernel process to suspend (or resume) in its main loop.
Advise a kernel process to suspend ( or resume ) in its main loop .
/*
	 * td_pflags should not be read by any thread other than
	 * curthread, but as long as this flag is invariant during the
	 * thread's lifetime, it is OK to check its state.
	 */ /*
	 * The caller of the primitive should have already checked that the
	 * thread is up and running, thus not being blocked by other
	 * conditions.
	 */