<!--
{
  "documentType" : "article",
  "framework" : "os",
  "identifier" : "/documentation/os/synchronization",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Synchronization"
}
-->

# Synchronization

Access low-level synchronization mechanisms to control state across threads.

## Discussion> Note: When possible, use higher-level synchronization primitives such as `pthread`, Grand Central Dispatch, or Swift’s concurrency features to control access to state across different threads. For more information, see <doc://com.apple.documentation/documentation/Swift/updating-an-app-to-use-strict-concurrency>.

## Topics

### Swift Wrappers

[`OSAllocatedUnfairLock`](/documentation/os/OSAllocatedUnfairLock)

A structure that creates an unfair lock.

[`OSAllocatedUnfairLockFlags`](/documentation/os/OSAllocatedUnfairLockFlags)

### Unfair Locking

[`os_unfair_lock`](/documentation/os/os_unfair_lock)

A structure that contains the data for an unfair lock.

[`OS_UNFAIR_LOCK_INIT`](/documentation/os/OS_UNFAIR_LOCK_INIT)

A value you use to initialize a new unfair lock.

[`os_unfair_lock_t`](/documentation/os/os_unfair_lock_t)

A pointer to an unfair lock structure.

[`os_unfair_lock_lock`](/documentation/os/os_unfair_lock_lock)

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

[`os_unfair_lock_trylock`](/documentation/os/os_unfair_lock_trylock)

Locks an unfair lock if it is not already locked.

[`os_unfair_lock_lock_with_flags`](/documentation/os/os_unfair_lock_lock_with_flags)

[`os_unfair_lock_unlock`](/documentation/os/os_unfair_lock_unlock)

Unlocks an unfair lock.

[`os_unfair_lock_assert_owner`](/documentation/os/os_unfair_lock_assert_owner)

Triggers an assertion if the calling thread doesn’t own the specified unfair lock.

[`os_unfair_lock_assert_not_owner`](/documentation/os/os_unfair_lock_assert_not_owner)

Triggers an assertion if the calling thread owns the specified unfair lock.

[`os_unfair_lock_flags_t`](/documentation/os/os_unfair_lock_flags_t)

### Futex Conditional Wait Primitives

[`os_sync_wait_on_address`](/documentation/os/os_sync_wait_on_address)

An atomic compare-and-wait operation, used to implement higher-level synchronization primitives.

[`os_sync_wait_on_address_with_deadline`](/documentation/os/os_sync_wait_on_address_with_deadline)

An atomic compare-and-wait operation with a deadline, used to implement higher-level synchronization primitives.

[`os_sync_wait_on_address_with_timeout`](/documentation/os/os_sync_wait_on_address_with_timeout)

An atomic compare-and-wait operation with a timeout, used to implement higher-level synchronization primitives.

[`os_sync_wait_on_address_flags_t`](/documentation/os/os_sync_wait_on_address_flags_t)

Flags to control futex wait behavior.

[`os_sync_wake_by_address_all`](/documentation/os/os_sync_wake_by_address_all)

An atomic operation that wakes all threads blocked on a futex wait, used to implement higher-level synchronization primitives.

[`os_sync_wake_by_address_any`](/documentation/os/os_sync_wake_by_address_any)

An atomic operation that wakes one thread blocked on a futex wait, used to implement higher-level synchronization primitives.

[`os_sync_wake_by_address_flags_t`](/documentation/os/os_sync_wake_by_address_flags_t)

Flags to control futex wake behavior.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)