6#ifndef NSBACI_RUNTIME_SEMAPHORE_H
7#define NSBACI_RUNTIME_SEMAPHORE_H
10#include <unordered_map>
25 explicit Semaphore(int32_t initialCount = 0) : count(initialCount) {}
30 bool wait(nsbaci::types::ThreadID currentThread);
34 nsbaci::types::ThreadID
signal();
43 std::queue<nsbaci::types::ThreadID> blocked;
59 std::unordered_map<MemoryAddr, nsbaci::services::runtime::Semaphore>;
bool hasWaiting() const
Check if any threads are blocked.
Definition semaphore.h:40
nsbaci::types::ThreadID signal()
V operation (signal/increment).
Definition semaphore.cpp:15
bool wait(nsbaci::types::ThreadID currentThread)
P operation (wait/decrement).
Definition semaphore.cpp:4
int32_t getCount() const
Get current count (for debugging).
Definition semaphore.h:37
Type definitions for compiler-related operations.
Runtime services namespace for nsbaci.
Type definitions namespace for nsbaci (runtime-specific).
std::unordered_map< MemoryAddr, nsbaci::services::runtime::Semaphore > SemaphoreTable
Maps memory addresses to semaphores.
Definition semaphore.h:58
Thread class declaration for nsbaci runtime service.