libnx  v4.7.0
Data Structures | Functions
semaphore.h File Reference

Thread synchronization based on Mutex. More...

#include "mutex.h"
#include "condvar.h"

Go to the source code of this file.

Data Structures

struct  Semaphore
 Semaphore structure. More...
 

Functions

void semaphoreInit (Semaphore *s, u64 initial_count)
 Initializes a semaphore and its internal counter. More...
 
void semaphoreSignal (Semaphore *s)
 Increments the Semaphore to allow other threads to continue. More...
 
void semaphoreWait (Semaphore *s)
 Decrements Semaphore and waits if 0. More...
 
bool semaphoreTryWait (Semaphore *s)
 Attempts to get lock without waiting. More...
 

Detailed Description

Thread synchronization based on Mutex.

Author
SciresM & Kevoot

Function Documentation

◆ semaphoreInit()

void semaphoreInit ( Semaphore s,
u64  initial_count 
)

Initializes a semaphore and its internal counter.

Parameters
sSemaphore object.
initial_countinitial value for internal counter (typically the # of free resources).

◆ semaphoreSignal()

void semaphoreSignal ( Semaphore s)

Increments the Semaphore to allow other threads to continue.

Parameters
sSemaphore object.

◆ semaphoreTryWait()

bool semaphoreTryWait ( Semaphore s)

Attempts to get lock without waiting.

Parameters
sSemaphore object.
Returns
true if no wait and successful lock, false otherwise.

◆ semaphoreWait()

void semaphoreWait ( Semaphore s)

Decrements Semaphore and waits if 0.

Parameters
sSemaphore object.