---
title: os_unfair_lock_lock
framework: os
role: symbol
role_heading: Function
path: os/os_unfair_lock_lock
---

# os_unfair_lock_lock

A low-level lock that allows waiters to block efficiently on contention.

## Declaration

```occ
extern void os_unfair_lock_lock(os_unfair_lock_t lock);
```

## Parameters

- `lock`: A pointer to the unfair lock to be locked.

## Discussion

Discussion Consider a lock’s data to be opaque and implementation-defined. Locks contain thread-ownership information that the system may use to attempt to resolve priority inversions. A lock must be unlocked only from the same thread in which it was locked. Attempting to unlock from a different thread causes a runtime error. A lock must not be accessed from multiple processes or threads via shared or multiply-mapped memory, because the lock implementation relies on the address of the lock value and owning process. note: This is a replacement for the deprecated OSSpinLock. This function doesn’t spin on contention, but instead waits in the kernel to be awoken by an unlock. Like OSSpinLock, this function does not enforce fairness or lock ordering—for example, an unlocker could potentially reacquire the lock immediately, before an awoken waiter gets an opportunity to attempt to acquire the lock. This may be advantageous for performance reasons, but also makes starvation of waiters a possibility.

## See Also

### Unfair Locking

- [os_unfair_lock](os/os_unfair_lock.md)
- [OS_UNFAIR_LOCK_INIT](os/os_unfair_lock_init.md)
- [os_unfair_lock_t](os/os_unfair_lock_t.md)
- [os_unfair_lock_trylock](os/os_unfair_lock_trylock.md)
- [os_unfair_lock_lock_with_flags](os/os_unfair_lock_lock_with_flags.md)
- [os_unfair_lock_unlock](os/os_unfair_lock_unlock.md)
- [os_unfair_lock_assert_owner](os/os_unfair_lock_assert_owner.md)
- [os_unfair_lock_assert_not_owner](os/os_unfair_lock_assert_not_owner.md)
- [os_unfair_lock_flags_t](os/os_unfair_lock_flags_t.md)
