KasperskyOS Community Edition 1.1
[Topic api_sync]

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.

Page top
[Topic kos_condvar_broadcast]

KosCondvarDeinit()

This function is declared in the kos/condvar.h file.

void KosCondvarDeinit(KosCondvar *condvar);

De-initializes the conditional variable condvar.

Page top
[Topic kos_condvar_deinit]

KosCondvarInit()

This function is declared in the kos/condvar.h file.

void KosCondvarInit(KosCondvar *condvar);

Initializes the conditional variable condvar.

Page top
[Topic kos_condvar_init]

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.

Page top
[Topic kos_condvar_signal]

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 top
[Topic kos_condvar_wait]

KosCondvarWaitTimeout()

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 top
[Topic kos_condvar_wait_timeout]

KosEventDeinit()

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).

Page top
[Topic kos_event_deinit]

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 top
[Topic kos_event_init]

KosEventReset()

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).

Page top
[Topic kos_event_reset]

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.

Page top
[Topic kos_event_set]

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 top
[Topic kos_event_wait]

KosEventWaitTimeout()

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 top
[Topic kos_event_wait_timeout]

KosMutexDeinit()

This function is declared in the kos/mutex.h file.

void KosMutexDeinit(KosMutex *mutex);

Deletes the specified mutex.

Page top
[Topic kos_mutex_deinit]

KosMutexInit()

This function is declared in the kos/mutex.h file.

void KosMutexInit(KosMutex *mutex);

Initializes the mutex in an unlocked state.

Page top
[Topic kos_mutex_init]

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.

Page top
[Topic kos_mutex_init_ex]

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 top
[Topic kos_mutex_lock]

KosMutexLockTimeout()

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 top
[Topic kos_mutex_lock_timeout]

KosMutexTryLock()

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 top
[Topic kos_mutex_try_lock]

KosMutexUnlock()

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.

Page top
[Topic kos_mutex_unlock]

KosRWLockDeinit()

This function is declared in the kos/rwlock.h file.

void KosRWLockDeinit(KosRWLock *rwlock);

De-initializes the read-write lock rwlock.

Page top
[Topic kos_rw_lock_deinit]

KosRWLockInit()

This function is declared in the kos/rwlock.h file.

void KosRWLockInit(KosRWLock *rwlock);

Initializes the read-write lock rwlock.

Page top
[Topic kos_rw_lock_init]

KosRWLockRead()

This function is declared in the kos/rwlock.h file.

void KosRWLockRead(KosRWLock *rwlock);

Locks the read threads.

Page top
[Topic kos_rw_lock_read]

KosRWLockTryRead()

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 top
[Topic kos_rw_lock_try_read]

KosRWLockTryWrite()

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 top
[Topic kos_rw_lock_try_write]

KosRWLockUnlock()

This function is declared in the kos/rwlock.h file.

void KosRWLockUnlock(KosRWLock *rwlock);

Removes the read-write lock rwlock.

Page top
[Topic kos_rw_lock_unlock]

KosRWLockWrite()

This function is declared in the kos/rwlock.h file.

void KosRWLockWrite(KosRWLock *rwlock);

Locks the write threads.

Page top
[Topic kos_rw_lock_write]

KosSemaphoreDeinit()

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.
Page top
[Topic kos_semaphore_deinit]

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.
Page top
[Topic kos_semaphore_init]

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.
Page top
[Topic kos_semaphore_signal]

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.
Page top
[Topic kos_semaphore_try_wait]

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.
Page top
[Topic kos_semaphore_wait]

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.
Page top
[Topic kos_semaphore_wait_timeout]