FreeBSD/sys/kern/subr_sleepqueue.c
/*
 * Check to see if we timed out.
 */
Check to see if we timed out.
Check to see if we timed out .
static int
sleepq_check_timeout(void)
{
	struct thread *td;
	td = curthread;
	THREAD_LOCK_ASSERT(td, MA_OWNED);
	if (td->td_flags & TDF_TIMEOUT) {
		td->td_flags &= ~TDF_TIMEOUT;
		return (EWOULDBLOCK);
	}
	if (td->td_flags & TDF_TIMOFAIL)
		td->td_flags &= ~TDF_TIMOFAIL;
	else if (_callout_stop_safe(&td->td_slpcallout, CS_EXECUTING, NULL)
	    == 0) {
		td->td_flags |= TDF_TIMEOUT;
		TD_SET_SLEEPING(td);
		mi_switch(SW_INVOL | SWT_SLEEPQTIMO, NULL);
	}
	return (0);
}
static int sleepq_check_timeout ( void ) { struct thread * td ; td = curthread ; THREAD_LOCK_ASSERT ( td , MA_OWNED ) ; if ( td -> td_flags & TDF_TIMEOUT ) { td -> td_flags &= ~ TDF_TIMEOUT ; return ( EWOULDBLOCK ) ; } if ( td -> td_flags & TDF_TIMOFAIL ) td -> td_flags &= ~ TDF_TIMOFAIL ; else if ( _callout_stop_safe ( & td -> td_slpcallout , CS_EXECUTING , NULL ) == 0 ) { td -> td_flags |= TDF_TIMEOUT ; TD_SET_SLEEPING ( td ) ; mi_switch ( SW_INVOL | SWT_SLEEPQTIMO , NULL ) ; } return ( 0 ) ; }
Check to see if we timed out.
Check to see if we timed out .
/*
	 * If TDF_TIMEOUT is set, we timed out.
	 */ /*
	 * If TDF_TIMOFAIL is set, the timeout ran after we had
	 * already been woken up.
	 */ /*
	 * If callout_stop() fails, then the timeout is running on
	 * another CPU, so synchronize with it to avoid having it
	 * accidentally wake up a subsequent sleep.
	 */