FreeBSD/sys/kern/kern_umtx.c
/*
 * Claim ownership of a PI mutex.
 */
Claim ownership of a PI mutex.
Claim ownership of a PI mutex .
static int
umtx_pi_claim(struct umtx_pi *pi, struct thread *owner)
{
	struct umtx_q *uq;
	int pri;
	mtx_lock(&umtx_lock);
	if (pi->pi_owner == owner) {
		mtx_unlock(&umtx_lock);
		return (0);
	}
	if (pi->pi_owner != NULL) {
		mtx_unlock(&umtx_lock);
		return (EPERM);
	}
	umtx_pi_setowner(pi, owner);
	uq = TAILQ_FIRST(&pi->pi_blocked);
	if (uq != NULL) {
		pri = UPRI(uq->uq_thread);
		thread_lock(owner);
		if (pri < UPRI(owner))
			sched_lend_user_prio(owner, pri);
		thread_unlock(owner);
	}
	mtx_unlock(&umtx_lock);
	return (0);
}
static int umtx_pi_claim ( struct umtx_pi * pi , struct thread * owner ) { struct umtx_q * uq ; int pri ; mtx_lock ( & umtx_lock ) ; if ( pi -> pi_owner == owner ) { mtx_unlock ( & umtx_lock ) ; return ( 0 ) ; } if ( pi -> pi_owner != NULL ) { mtx_unlock ( & umtx_lock ) ; return ( EPERM ) ; } umtx_pi_setowner ( pi , owner ) ; uq = TAILQ_FIRST ( & pi -> pi_blocked ) ; if ( uq != NULL ) { pri = UPRI ( uq -> uq_thread ) ; thread_lock ( owner ) ; if ( pri < UPRI ( owner ) ) sched_lend_user_prio ( owner , pri ) ; thread_unlock ( owner ) ; } mtx_unlock ( & umtx_lock ) ; return ( 0 ) ; }
Claim ownership of a PI mutex.
Claim ownership of a PI mutex .
/*
		 * userland may have already messed the mutex, sigh.
		 */