FreeBSD/sys/kern/kern_umtx.c
/*
 * Signal a userland condition variable.
 */
Signal a userland condition variable.
Signal a userland condition variable .
static int
do_cv_signal(struct thread *td, struct ucond *cv)
{
	struct umtx_key key;
	int error, cnt, nwake;
	uint32_t flags;
	error = fueword32(&cv->c_flags, &flags);
	if (error == -1)
		return (EFAULT);
	if ((error = umtx_key_get(cv, TYPE_CV, GET_SHARE(flags), &key)) != 0)
		return (error);	
	umtxq_lock(&key);
	umtxq_busy(&key);
	cnt = umtxq_count(&key);
	nwake = umtxq_signal(&key, 1);
	if (cnt <= nwake) {
		umtxq_unlock(&key);
		error = suword32(&cv->c_has_waiters, 0);
		if (error == -1)
			error = EFAULT;
		umtxq_lock(&key);
	}
	umtxq_unbusy(&key);
	umtxq_unlock(&key);
	umtx_key_release(&key);
	return (error);
}
static int do_cv_signal ( struct thread * td , struct ucond * cv ) { struct umtx_key key ; int error , cnt , nwake ; uint32_t flags ; error = fueword32 ( & cv -> c_flags , & flags ) ; if ( error == -1 ) return ( EFAULT ) ; if ( ( error = umtx_key_get ( cv , TYPE_CV , GET_SHARE ( flags ) , & key ) ) != 0 ) return ( error ) ; umtxq_lock ( & key ) ; umtxq_busy ( & key ) ; cnt = umtxq_count ( & key ) ; nwake = umtxq_signal ( & key , 1 ) ; if ( cnt <= nwake ) { umtxq_unlock ( & key ) ; error = suword32 ( & cv -> c_has_waiters , 0 ) ; if ( error == -1 ) error = EFAULT ; umtxq_lock ( & key ) ; } umtxq_unbusy ( & key ) ; umtxq_unlock ( & key ) ; umtx_key_release ( & key ) ; return ( error ) ; }
Signal a userland condition variable.
Signal a userland condition variable .