FreeBSD/sys/kern/subr_sleepqueue.c
/*
 * Resumes a specific thread from the sleep queue associated with a specific
 * wait channel if it is on that queue.
 */
Resumes a specific thread from the sleep queue associated with a specific
wait channel if it is on that queue.
Resumes a specific thread from the sleep queue associated with a specific wait channel if it is on that queue .
void
sleepq_remove(struct thread *td, void *wchan)
{
	struct sleepqueue *sq;
	int wakeup_swapper;
	MPASS(wchan != NULL);
	sleepq_lock(wchan);
	sq = sleepq_lookup(wchan);
	if (!TD_ON_SLEEPQ(td) || td->td_wchan != wchan) {
		sleepq_release(wchan);
		return;
	}
	thread_lock(td);
	MPASS(sq != NULL);
	MPASS(td->td_wchan == wchan);
	wakeup_swapper = sleepq_resume_thread(sq, td, 0);
	thread_unlock(td);
	sleepq_release(wchan);
	if (wakeup_swapper)
		kick_proc0();
}
void sleepq_remove ( struct thread * td , void * wchan ) { struct sleepqueue * sq ; int wakeup_swapper ; MPASS ( wchan != NULL ) ; sleepq_lock ( wchan ) ; sq = sleepq_lookup ( wchan ) ; if ( ! TD_ON_SLEEPQ ( td ) || td -> td_wchan != wchan ) { sleepq_release ( wchan ) ; return ; } thread_lock ( td ) ; MPASS ( sq != NULL ) ; MPASS ( td -> td_wchan == wchan ) ; wakeup_swapper = sleepq_resume_thread ( sq , td , 0 ) ; thread_unlock ( td ) ; sleepq_release ( wchan ) ; if ( wakeup_swapper ) kick_proc0 ( ) ; }
Resumes a specific thread from the sleep queue associated with a specific
 wait channel if it is on that queue.
Resumes a specific thread from the sleep queue associated with a specific wait channel if it is on that queue .
/*
	 * Look up the sleep queue for this wait channel, then re-check
	 * that the thread is asleep on that channel, if it is not, then
	 * bail.
	 */ /*
	 * We can not lock the thread here as it may be sleeping on a
	 * different sleepq.  However, holding the sleepq lock for this
	 * wchan can guarantee that we do not miss a wakeup for this
	 * channel.  The asserts below will catch any false positives.
	 */ /* Thread is asleep on sleep queue sq, so wake it up. */