nsbaci 1.0
Loading...
Searching...
No Matches
nsbaci::services::runtime::Semaphore Class Reference

Counting semaphore for process synchronization. More...

#include <semaphore.h>

Public Member Functions

 Semaphore (int32_t initialCount=0)
bool wait (nsbaci::types::ThreadID currentThread)
 P operation (wait/decrement).
nsbaci::types::ThreadID signal ()
 V operation (signal/increment).
int32_t getCount () const
 Get current count (for debugging).
bool hasWaiting () const
 Check if any threads are blocked.

Detailed Description

Counting semaphore for process synchronization.

Created at runtime when StoreSemaphore instruction executes.

Member Function Documentation

◆ signal()

nsbaci::types::ThreadID nsbaci::services::runtime::Semaphore::signal ( )

V operation (signal/increment).

Returns
ThreadID to wake, or 0 if none waiting

◆ wait()

bool nsbaci::services::runtime::Semaphore::wait ( nsbaci::types::ThreadID currentThread)

P operation (wait/decrement).

Parameters
currentThreadThe thread attempting to wait
Returns
true if thread can proceed, false if it must block

The documentation for this class was generated from the following files: