184__always_inline
static inline void
229__always_inline
static inline uint16_t
235 return ((*(uint32_t *)&(lock->lockWord)) & 0x0000ffff);
352 int (*mutexLock)(TimeoutArgument,
void *),
353 int (*mutexUnlock)(
void *));
356 void (*callback)(
__if_c(
void)))
363 int __cheriot_libcall run_once_slow_path(
struct OnceState * state,
364 void (*callback)(
__if_c(
void)));
367 if (atomic_load_explicit(
368 &state->state, __if_cxx(std::) memory_order_relaxed) ==
OnceStateRun)
373 return run_once_slow_path(state, callback);
int __cheri_libcall semaphore_get(TimeoutArgument timeout, struct CountingSemaphoreState *semaphore)
Semaphore get operation, decrements the semaphore count.
static void flaglock_lock(struct FlagLockState *lock)
Convenience wrapper to acquire a lock with an unlimited timeout.
int __cheri_libcall recursivemutex_unlock(struct RecursiveMutexState *mutex)
Unlock a recursive mutex.
int __cheriot_libcall condition_variable_notify(struct ConditionVariableState *conditionVariable, uint32_t waiters)
Signal the condition variable and wake up to the number of waiters specified by the second argument.
static uint16_t flaglock_priority_inheriting_get_owner_thread_id(struct FlagLockState *lock)
Return the thread ID of the owner of the lock.
void __cheri_libcall flaglock_unlock(struct FlagLockState *lock)
Unlock a flag lock.
static void flaglock_priority_inheriting_lock(struct FlagLockState *lock)
Convenience wrapper to acquire a lock with an unlimited timeout.
void __cheri_libcall flaglock_upgrade_for_destruction(struct FlagLockState *lock)
Set a flag lock in destruction mode.
void __cheri_libcall ticketlock_unlock(struct TicketLockState *lock)
Release a ticket lock.
int __cheriot_libcall barrier_timed_wait(TimeoutArgument timeout, struct BarrierState *barrier)
Wait on a barrier.
static int barrier_wait(struct BarrierState *barrier)
Helper that calls barrier_timed_wait with an unlimited timeout.
int __cheri_libcall flaglock_trylock(TimeoutArgument timeout, struct FlagLockState *lock)
Try to lock a flag lock.
int __cheri_libcall flaglock_priority_inheriting_trylock(TimeoutArgument timeout, struct FlagLockState *lock)
Try to lock a flag lock.
static int run_once(struct OnceState *state, void(*callback)(__if_c(void)))
int __cheri_libcall recursivemutex_trylock(TimeoutArgument timeout, struct RecursiveMutexState *lock)
Try to acquire a recursive mutex.
OnceStateMachineStates
State-machine states for run-once functions.
@ OnceStateRun
The function has run to completion.
@ OnceStateNotRun
The function has not run yet.
@ OnceStateRunning
The function has started running but has not yet finished.
int __cheriot_libcall condition_variable_wait(TimeoutArgument t, struct ConditionVariableState *conditionVariable, void *mutex, int(*mutexLock)(TimeoutArgument, void *), int(*mutexUnlock)(void *))
Wait on a condition variable.
int __cheri_libcall semaphore_put(struct CountingSemaphoreState *semaphore)
Semaphore put operation.
void __cheri_libcall ticketlock_lock(struct TicketLockState *lock)
Acquire a ticket lock.
This file implements the C11 and C++23 C atomics interfaces.
_Atomic(uint32_t) remaining
The number of threads that have to rendezvous with this barrier to allow waiters to wake.
Condition variable state.
_Atomic(uint32_t) sequenceCounter
Sequence counter used to wait and notify waiters.
State for a counting semaphore.
_Atomic(uint32_t) count
The current counter value.
uint32_t maxCount
The maximum value for the counter.
_Atomic(uint32_t) lockWord
The lock word.
Synchronisation state for run-once functions.
State for a recursive mutex.
uint16_t depth
The count of the times the lock has been acquired by the same thread.
struct FlagLockState lock
The underlying lock.
Ticket locks use two monotonic counters to store the lock state.
_Atomic(uint32_t) current
The value for the current ticket holder.
_Atomic(uint32_t) next
The value for the next ticket to be granted.
Structure representing a timeout.
Functions and types used for thread management.
This file contains the types used for timeouts across scheduler APIs.
static const Ticks UnlimitedTimeout
Value indicating an unbounded timeout for use with Timeout.
union __if_c() __TimeoutArgument
A union to hold timeouts that are passed down to end up in the scheduler.