---
name: "SDL_CreateSemaphore"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_CreateSemaphore"
---

# SDL\_CreateSemaphore(3)

Create a semaphore.

## NAME

SDL\_CreateSemaphore - Create a semaphore.

## HEADER FILE

Defined in SDL3/SDL\_mutex.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**SDL\_Semaphore \* SDL\_CreateSemaphore(Uint32 initial\_value);**

## DESCRIPTION

This function creates a new semaphore and initializes it with the value **initial\_value** . Each wait operation on the semaphore will atomically decrement the semaphore value and potentially block if the semaphore value is 0. Each post operation will atomically increment the semaphore value and wake waiting threads and allow them to retry the wait operation.

## FUNCTION PARAMETERS

- *initial\_value*

  the starting value of the semaphore.

## RETURN VALUE

( **SDL\_Semaphore**\
  \*) Returns a new semaphore or NULL on failure; call  **SDL\_GetError** () for more information.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_DestroySemaphore**(3)](/SDL_DestroySemaphore/3.md), **•**(3), [**SDL\_SignalSemaphore**(3)](/SDL_SignalSemaphore/3.md), **•**(3), [**SDL\_TryWaitSemaphore**(3)](/SDL_TryWaitSemaphore/3.md), **•**(3), [**SDL\_GetSemaphoreValue**(3)](/SDL_GetSemaphoreValue/3.md), **•**(3), [**SDL\_WaitSemaphore**(3)](/SDL_WaitSemaphore/3.md), **•**(3), [**SDL\_WaitSemaphoreTimeout**(3)](/SDL_WaitSemaphoreTimeout/3.md)
