<!--
{
  "availability" : [
    "iOS: 17.4.0 -",
    "iPadOS: 17.4.0 -",
    "macCatalyst: 17.4.0 -",
    "macOS: 14.4.0 -",
    "tvOS: 17.4.0 -",
    "visionOS: 1.1.0 -",
    "watchOS: 10.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "os",
  "identifier" : "/documentation/os/os_sync_wake_by_address_all",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "os"
    ],
    "preciseIdentifier" : "c:@F@os_sync_wake_by_address_all"
  },
  "title" : "os_sync_wake_by_address_all"
}
-->

# 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.

```
extern int os_sync_wake_by_address_all(void *addr, size_t size, os_sync_wake_by_address_flags_t flags);
```

## Parameters

`addr`

The user-space address waited on to wake. This address must be aligned to `size`.

`size`

The size of the wait value, in bytes. Values can be 4 or 8 bytes, where 4-byte values use the lower bytes of `value`.

`flags`

Flags for the operation.

## Return Value

Returns 0 on success, and -1 on error with `errno` set.

## Discussion

This function wakes all threads waiting on `addr`. There’s no guarantee on the order threads wake.

Pass consistent values across wait and wake APIs for `addr`, `size`, and `flags`. See [`os_sync_wake_by_address_flags_t`](/documentation/os/os_sync_wake_by_address_flags_t) for details.

> Important: Use this function only for implementing synchronization primitives that don’t have a sense of ownership,
> such as condition variables or semaphores. In particular, this function doesn’t provide priority inversion avoidance.
> For locking APIs, use existing OS primitives, such as `pthread` threads or
> <doc://com.apple.os/documentation/os/synchronization#Unfair-Locking> APIs. For synchronization and threading managed by the OS, use a higher-level API, such
> as <doc://com.apple.documentation/documentation/Dispatch>.

### Error Codes

When this function returns `-1`, the global variable `errno` contains one of these values, indicating the corresponding error.

|Error code|Description                                                                                                                                                                           |
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|`EINVAL`  |Invalid flags or size.![](spacer)The `addr` passed is NULL.![](spacer)The operation associated with the existing kernel state at `addr` is inconsistent with other function arguments.|
|`ENOENT`  |There are no compare-and-wait operations on `addr`.                                                                                                                                   |
|`EDOM`    |The `addr` is in use for non-compare-and-wait synchronization.                                                                                                                        |

---

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)