This is an old revision of the document!
kgi_mutex_init()
Initialize a pre-allocated mutex.
void kgi_mutex_init( /* Comment: pointer to the mutex to initialize */ kgi_mutex_t *mtx, /* Comment: name of the mutex */ const char *name );
kgi_mutex_done()
Release a mutex. Memory allocated for the mutex itself is not freed.
void kgi_mutex_done( /* Comment: pointer to the mutex to release */ kgi_mutex_t *mtx );
kgi_mutex_lock()
void kgi_mutex_lock(kgi_mutex_t *mtx);
kg_mutex_unlock()
void kgi_mutex_unlock(kgi_mutex_t *mtx);
kgi_mutex_wait()
Wait on the mutex e.g unlock the mutex and add the thread to the list of waiting threads on this mutex. When the thread is made runnable again, it owns the mutex.
Important: the mutex must be already locked by the current running thread when calling kgi_mutex_wait().
void kgi_mutex_wait( /* Comment: pointer to the mutex to wait on */ kgi_mutex_t *mtx );
kgi_mutex_signal()
Wakeup (unblock) threads waiting on the mutex.
If unblock_all is TRUE then unblock all waiters otherwise only one.
void kgi_mutex_signal( /* Comment: pointer to the mutex processes are blocked on */ kgi_mutex_t *mtx, /* Comment: TRUE = unblock all processes waiting on the mutex, FALSE = unblock only the next one */ int unblock_all );