FreeBSD/sys/kern/kern_umtx.c
/*
 * Put thread into sleep state, before sleeping, check if
 * thread was removed from umtx queue.
 */
Put thread into sleep state, before sleeping, check if
thread was removed from umtx queue.
Put thread into sleep state before sleeping check if thread was removed from umtx queue .
static inline int
umtxq_sleep(struct umtx_q *uq, const char *wmesg, struct abs_timeout *abstime)
{
	struct umtxq_chain *uc;
	int error, timo;
	uc = umtxq_getchain(&uq->uq_key);
	UMTXQ_LOCKED_ASSERT(uc);
	for (;;) {
		if (!(uq->uq_flags & UQF_UMTXQ))
			return (0);
		if (abstime != NULL) {
			timo = abs_timeout_gethz(abstime);
			if (timo < 0)
				return (ETIMEDOUT);
		} else
			timo = 0;
		error = msleep(uq, &uc->uc_lock, PCATCH | PDROP, wmesg, timo);
		if (error != EWOULDBLOCK) {
			umtxq_lock(&uq->uq_key);
			break;
		}
		if (abstime != NULL)
			abs_timeout_update(abstime);
		umtxq_lock(&uq->uq_key);
	}
	return (error);
}
static inline int umtxq_sleep ( struct umtx_q * uq , const char * wmesg , struct abs_timeout * abstime ) { struct umtxq_chain * uc ; int error , timo ; uc = umtxq_getchain ( & uq -> uq_key ) ; UMTXQ_LOCKED_ASSERT ( uc ) ; for ( ; ; ) { if ( ! ( uq -> uq_flags & UQF_UMTXQ ) ) return ( 0 ) ; if ( abstime != NULL ) { timo = abs_timeout_gethz ( abstime ) ; if ( timo < 0 ) return ( ETIMEDOUT ) ; } else timo = 0 ; error = msleep ( uq , & uc -> uc_lock , PCATCH | PDROP , wmesg , timo ) ; if ( error != EWOULDBLOCK ) { umtxq_lock ( & uq -> uq_key ) ; break ; } if ( abstime != NULL ) abs_timeout_update ( abstime ) ; umtxq_lock ( & uq -> uq_key ) ; } return ( error ) ; }
Put thread into sleep state, before sleeping, check if
 thread was removed from umtx queue.
Put thread into sleep state before sleeping check if thread was removed from umtx queue .