FreeBSD/sys/kern/subr_sleepqueue.c
/*
 * Abort a thread as if an interrupt had occurred.  Only abort
 * interruptible waits (unfortunately it isn't safe to abort others).
 */
Abort a thread as if an interrupt had occurred.  Only abort
interruptible waits (unfortunately it isn't safe to abort others).
Abort a thread as if an interrupt had occurred . Only abort interruptible waits ( unfortunately it isn ' t safe to abort others ) .
int
sleepq_abort(struct thread *td, int intrval)
{
	struct sleepqueue *sq;
	void *wchan;
	THREAD_LOCK_ASSERT(td, MA_OWNED);
	MPASS(TD_ON_SLEEPQ(td));
	MPASS(td->td_flags & TDF_SINTR);
	MPASS(intrval == EINTR || intrval == ERESTART);
	if (td->td_flags & TDF_TIMEOUT)
		return (0);
	CTR3(KTR_PROC, "sleepq_abort: thread %p (pid %ld, %s)",
	    (void *)td, (long)td->td_proc->p_pid, (void *)td->td_name);
	td->td_intrval = intrval;
	td->td_flags |= TDF_SLEEPABORT;
	if (!TD_IS_SLEEPING(td))
		return (0);
	wchan = td->td_wchan;
	MPASS(wchan != NULL);
	sq = sleepq_lookup(wchan);
	MPASS(sq != NULL);
	return (sleepq_resume_thread(sq, td, 0));
}
int sleepq_abort ( struct thread * td , int intrval ) { struct sleepqueue * sq ; void * wchan ; THREAD_LOCK_ASSERT ( td , MA_OWNED ) ; MPASS ( TD_ON_SLEEPQ ( td ) ) ; MPASS ( td -> td_flags & TDF_SINTR ) ; MPASS ( intrval == EINTR || intrval == ERESTART ) ; if ( td -> td_flags & TDF_TIMEOUT ) return ( 0 ) ; CTR3 ( KTR_PROC , " " , ( void * ) td , ( long ) td -> td_proc -> p_pid , ( void * ) td -> td_name ) ; td -> td_intrval = intrval ; td -> td_flags |= TDF_SLEEPABORT ; if ( ! TD_IS_SLEEPING ( td ) ) return ( 0 ) ; wchan = td -> td_wchan ; MPASS ( wchan != NULL ) ; sq = sleepq_lookup ( wchan ) ; MPASS ( sq != NULL ) ; return ( sleepq_resume_thread ( sq , td , 0 ) ) ; }
Abort a thread as if an interrupt had occurred.
Abort a thread as if an interrupt had occurred .
/*
	 * If the TDF_TIMEOUT flag is set, just leave. A
	 * timeout is scheduled anyhow.
	 */ /*
	 * If the thread has not slept yet it will find the signal in
	 * sleepq_catch_signals() and call sleepq_resume_thread.  Otherwise
	 * we have to do it here.
	 */ /* Thread is asleep on sleep queue sq, so wake it up. */