Contents
- Synchronization primitives
- KosCondvarBroadcast()
- KosCondvarDeinit()
- KosCondvarInit()
- KosCondvarSignal()
- KosCondvarWait()
- KosCondvarWaitTimeout()
- KosEventDeinit()
- KosEventInit()
- KosEventReset()
- KosEventSet()
- KosEventWait()
- KosEventWaitTimeout()
- KosMutexDeinit()
- KosMutexInit()
- KosMutexInitEx()
- KosMutexLock()
- KosMutexLockTimeout()
- KosMutexTryLock()
- KosMutexUnlock()
- KosRWLockDeinit()
- KosRWLockInit()
- KosRWLockRead()
- KosRWLockTryRead()
- KosRWLockTryWrite()
- KosRWLockUnlock()
- KosRWLockWrite()
- KosSemaphoreDeinit()
- KosSemaphoreInit()
- KosSemaphoreSignal()
- KosSemaphoreTryWait()
- KosSemaphoreWait()
- KosSemaphoreWaitTimeout()
KosCondvarBroadcast()
This function is declared in the kos/condvar.h
file.
void KosCondvarBroadcast(KosCondvar *condvar);
This function wakes all threads from the queue of threads that are blocked by the conditional variable condvar
.
KosCondvarDeinit()
This function is declared in the kos/condvar.h
file.
void KosCondvarDeinit(KosCondvar *condvar);
De-initializes the conditional variable condvar
.
KosCondvarInit()
This function is declared in the kos/condvar.h
file.
void KosCondvarInit(KosCondvar *condvar);
Initializes the conditional variable condvar
.
KosCondvarSignal()
This function is declared in the kos/condvar.h
file.
void KosCondvarSignal(KosCondvar *condvar);
This function wakes one thread from the queue of threads that are blocked by the conditional variable condvar
.
KosCondvarWait()
This function is declared in the kos/condvar.h
file.
Retcode KosCondvarWait(KosCondvar *condvar, KosMutex *mutex);
This function blocks execution of the current thread via the conditional variable condvar
until it is awakened using KosCondvarSignal() or KosCondvarBroadcast().
mutex
refers to the mutex that will be used for protecting the critical section.
If successful, the function returns rcOk.
Page topKosCondvarWaitTimeout()
This function is declared in the kos/condvar.h
file.
Retcode KosCondvarWaitTimeout(KosCondvar *condvar, KosMutex *mutex,
rtl_uint32_t mdelay);
This function blocks execution of the current thread via the conditional variable condvar
until it is awakened using KosCondvarSignal() or KosCondvarBroadcast(). The thread is blocked for no more than mdelay
(in milliseconds).
mutex
refers to the mutex that will be used for protecting the critical section.
This function returns rcOk if successful, or rcTimeout if it times out.
Page topKosEventDeinit()
This function is declared in the kos/event.h
file.
void KosEventDeinit(KosEvent *event);
This function frees the resources associated with an event
(deletes the event).
KosEventInit()
This function is declared in the kos/event.h
file.
void KosEventInit(KosEvent *event);
This function creates an event
.
The created event is in a non-signaling state.
Page topKosEventReset()
This function is declared in the kos/event.h
file.
void KosEventReset(KosEvent *event);
This function switches an event
to the non-signaling state (resets the event).
KosEventSet()
This function is declared in the kos/event.h
file.
void KosEventSet(KosEvent *event);
This function switches an event
to the signaling state (signals the event) and thereby wakes all threads that are waiting for it.
KosEventWait()
This function is declared in the kos/event.h
file.
void KosEventWait(KosEvent *event, rtl_bool reset);
Waits for the event to switch to signaling state.
The reset
parameter indicates whether the event should be automatically reset when the wait successfully ends.
Returns rcOk if successful.
Page topKosEventWaitTimeout()
This function is declared in the kos/event.h
file.
Retcode KosEventWaitTimeout(KosEvent *event, rtl_bool reset,
rtl_uint32_t msec);
Waits for the event to switch to signaling state for a period of msec
(milliseconds).
The reset
parameter indicates whether the event should be automatically reset when the wait successfully ends.
This function returns rcOk if successful, or rcTimeout if the timeout is exceeded.
Page topKosMutexDeinit()
This function is declared in the kos/mutex.h
file.
void KosMutexDeinit(KosMutex *mutex);
Deletes the specified mutex
.
KosMutexInit()
This function is declared in the kos/mutex.h
file.
void KosMutexInit(KosMutex *mutex);
Initializes the mutex
in an unlocked state.
KosMutexInitEx()
This function is declared in the kos/mutex.h
file.
void KosMutexInitEx(KosMutex *mutex, int recursive);
Initializes the mutex
in an unlocked state.
To initialize a recursive mutex, you need to pass the value 1 to the recursive
parameter.
KosMutexLock()
This function is declared in the kos/mutex.h
file.
void KosMutexLock(KosMutex *mutex);
Captures the specified mutex
.
If the mutex is already captured, the thread is locked and waits to be unlocked.
Page topKosMutexLockTimeout()
This function is declared in the kos/mutex.h
file.
Retcode KosMutexLockTimeout(KosMutex *mutex, rtl_uint32_t mdelay);
Captures the specified mutex
.
If the mutex is already captured, the thread is locked for mdelay
and waits to be unlocked.
This function returns rcOk if successful, or rcTimeout if it times out.
Page topKosMutexTryLock()
This function is declared in the kos/mutex.h
file.
Retcode KosMutexTryLock(KosMutex *mutex);
Attempts to capture the specified mutex
.
This function returns rcOk if the mutex could be captured, and returns rcBusy if the mutex could not be captured because it is already captured.
Page topKosMutexUnlock()
This function is declared in the kos/mutex.h
file.
void KosMutexUnlock(KosMutex *mutex);
Unlocks the specified mutex
.
To unlock a recursive mutex, you need to perform the same amount of KosMutexUnlock()
calls to match the amount of times the recursive mutex was locked.
KosRWLockDeinit()
This function is declared in the kos/rwlock.h
file.
void KosRWLockDeinit(KosRWLock *rwlock);
De-initializes the read-write lock rwlock
.
KosRWLockInit()
This function is declared in the kos/rwlock.h
file.
void KosRWLockInit(KosRWLock *rwlock);
Initializes the read-write lock rwlock
.
KosRWLockRead()
This function is declared in the kos/rwlock.h
file.
void KosRWLockRead(KosRWLock *rwlock);
Locks the read threads.
Page topKosRWLockTryRead()
This function is declared in the kos/rwlock.h
file.
Retcode KosRWLockTryRead(KosRWLock *rwlock);
Attempts to lock the read threads.
If successful, the function returns rcOk.
Page topKosRWLockTryWrite()
This function is declared in the kos/rwlock.h
file.
Retcode KosRWLockTryWrite(KosRWLock *rwlock);
Attempts to lock the write threads.
If successful, the function returns rcOk.
Page topKosRWLockUnlock()
This function is declared in the kos/rwlock.h
file.
void KosRWLockUnlock(KosRWLock *rwlock);
Removes the read-write lock rwlock
.
KosRWLockWrite()
This function is declared in the kos/rwlock.h
file.
void KosRWLockWrite(KosRWLock *rwlock);
Locks the write threads.
Page topKosSemaphoreDeinit()
This function is declared in the kos/semaphore.h
file.
Retcode KosSemaphoreDeinit(KosSemaphore *semaphore);
This function destroys the specified semaphore
that was previously initialized by the KosSemaphoreInit()
function.
It is safe to destroy an initialized semaphore on which there are currently no locked threads. There could be an unpredictable effect from destroying a semaphore on which other threads are currently locked.
The function returns the following:
- rcOk if successful;
- rcInvalidArgument, if the
semaphore
points to an invalid semaphore; - rcFail if there are threads being locked by this semaphore.
KosSemaphoreInit()
This function is declared in the kos/semaphore.h
file.
Retcode KosSemaphoreInit(KosSemaphore *semaphore, unsigned count);
Initializes the defined semaphore
with the initial count
value.
The function returns the following:
- rcOk if successful;
- rcInvalidArgument, if the
semaphore
points to an invalid semaphore; - rcFail if the
count
value exceeds KOS_SEMAPHORE_VALUE_MAX.
KosSemaphoreSignal()
This function is declared in the kos/semaphore.h
file.
Retcode KosSemaphoreSignal(KosSemaphore *semaphore);
Frees (signals) the defined semaphore
.
The function returns the following:
- rcOk if successful;
- rcInvalidArgument, if the
semaphore
points to an invalid semaphore.
KosSemaphoreTryWait()
This function is declared in the kos/semaphore.h
file.
Retcode KosSemaphoreTryWait(KosSemaphore *semaphore);
Attempts to acquire the defined semaphore
.
The function returns the following:
- rcOk if successful;
- rcInvalidArgument, if the
semaphore
points to an invalid semaphore; - rcBusy if the semaphore is already acquired.
KosSemaphoreWait()
This function is declared in the kos/semaphore.h
file.
Retcode KosSemaphoreWait(KosSemaphore *semaphore);
Waits for acquisition of the defined semaphore
.
The function returns the following:
- rcOk if successful;
- rcInvalidArgument, if the
semaphore
points to an invalid semaphore.
KosSemaphoreWaitTimeout()
This function is declared in the kos/semaphore.h
file.
Retcode KosSemaphoreWaitTimeout(KosSemaphore *semaphore, rtl_uint32_t mdelay);
Waits for acquisition of the defined semaphore
for a period of mdelay
in milliseconds.
The function returns the following:
- rcOk if successful;
- rcInvalidArgument, if the
semaphore
points to an invalid semaphore; - rcTimeout if the timeout expired.