FreeBSD/sys/kern/kern_umtx.c
/*
 * Lock a userland POSIX mutex.
 */
Lock a userland POSIX mutex.
Lock a userland POSIX mutex .
static int
do_lock_umutex(struct thread *td, struct umutex *m,
    struct _umtx_time *timeout, int mode)
{
	uint32_t flags;
	int error;
	error = fueword32(&m->m_flags, &flags);
	if (error == -1)
		return (EFAULT);
	switch (flags & (UMUTEX_PRIO_INHERIT | UMUTEX_PRIO_PROTECT)) {
	case 0:
		error = do_lock_normal(td, m, flags, timeout, mode);
		break;
	case UMUTEX_PRIO_INHERIT:
		error = do_lock_pi(td, m, flags, timeout, mode);
		break;
	case UMUTEX_PRIO_PROTECT:
		error = do_lock_pp(td, m, flags, timeout, mode);
		break;
	default:
		return (EINVAL);
	}
	if (timeout == NULL) {
		if (error == EINTR && mode != _UMUTEX_WAIT)
			error = ERESTART;
	} else {
		if (error == ERESTART)
			error = EINTR;
	}
	return (error);
}
static int do_lock_umutex ( struct thread * td , struct umutex * m , struct _umtx_time * timeout , int mode ) { uint32_t flags ; int error ; error = fueword32 ( & m -> m_flags , & flags ) ; if ( error == -1 ) return ( EFAULT ) ; switch ( flags & ( UMUTEX_PRIO_INHERIT | UMUTEX_PRIO_PROTECT ) ) { case 0 : error = do_lock_normal ( td , m , flags , timeout , mode ) ; break ; case UMUTEX_PRIO_INHERIT : error = do_lock_pi ( td , m , flags , timeout , mode ) ; break ; case UMUTEX_PRIO_PROTECT : error = do_lock_pp ( td , m , flags , timeout , mode ) ; break ; default : return ( EINVAL ) ; } if ( timeout == NULL ) { if ( error == EINTR && mode != _UMUTEX_WAIT ) error = ERESTART ; } else { if ( error == ERESTART ) error = EINTR ; } return ( error ) ; }
Lock a userland POSIX mutex.
Lock a userland POSIX mutex .
/* Timed-locking is not restarted. */