#include "mutex.h"
#include "debug.h"
#include "semaphore.h"
#include "errnums.h"
#include "int.h"
#include "io.h"
Functions | |
void | mutex_init (mutex_t *mtx) |
Initilaization of the mutex. This function initiliaze structure for the mutex. | |
void | mutex_destroy (mutex_t *mtx) |
Free semaphore structures. Function call panic if any thread is waiting on semaphore. | |
void | mutex_lock_nondebug (mutex_t *mtx) |
Attempts to lock mutex, it blocks calling thread on mutex if mutex already locked. | |
void | mutex_lock_debug (mutex_t *mtx) |
Attempts to lock mutex, it blocks calling thread on mutex if mutex already locked. | |
int | mutex_lock_timeout_nondebug (mutex_t *mtx, const unsigned int usec) |
An attempt to lock mutex with maximum usec waiting time. | |
int | mutex_lock_timeout_debug (mutex_t *mtx, const unsigned int usec) |
An attempt to lock mutex with maximum usec waiting time. | |
void | mutex_unlock_nondebug (mutex_t *mtx) |
unlock mutex, wake up all threads waiting on it. | |
void | mutex_unlock_debug (mutex_t *mtx) |
unlock mutex, wake up all threads waiting on it. |
Mutexes are implemented as binar semaphores with a handle to a thread owning it. There are implemented two grups of functions in this file. Firs are debug and the second is non debug. The difference betwen it is, that first
void mutex_destroy | ( | mutex_t * | mtx | ) |
Free semaphore structures. Function call panic if any thread is waiting on semaphore.
mtx | - mutex to be destroyed |
void mutex_lock_debug | ( | mutex_t * | mtx | ) |
Attempts to lock mutex, it blocks calling thread on mutex if mutex already locked.
This is a Debug version of this function. If thread unlocking is not owner cause kernel panic
mtx | - mutex to be locked |
void mutex_lock_nondebug | ( | mutex_t * | mtx | ) |
Attempts to lock mutex, it blocks calling thread on mutex if mutex already locked.
Non debug version, dont care if thread unlocking the mutex is owner of it
mtx | - mutex to be locked |
int mutex_lock_timeout_debug | ( | mutex_t * | mtx, | |
const unsigned int | usec | |||
) |
An attempt to lock mutex with maximum usec waiting time.
This is a Debug version of this function. If thread unlocking is not owner cause kernel panic
mtx | - mutex to | |
usec | in usec to wait on the semaphore. |
int mutex_lock_timeout_nondebug | ( | mutex_t * | mtx, | |
const unsigned int | usec | |||
) |
An attempt to lock mutex with maximum usec waiting time.
Non debug version, dont care if thread unlocking the mutex is owner of it
mtx | - mutex to | |
usec | in usec to wait on the semaphore. |
void mutex_unlock_debug | ( | mutex_t * | mtx | ) |
unlock mutex, wake up all threads waiting on it.
Function unlock mutex, wakeup all the threads vaiting on synchro primitives. This is a Debug version of this function. If thread unlocking is not owner cause kernel panic
mtx | - mutex to be unlocked |
void mutex_unlock_nondebug | ( | mutex_t * | mtx | ) |
unlock mutex, wake up all threads waiting on it.
Function unlock mutex, wakeup all the threads vaiting on synchro primitives. Non debug version, dont care if thread unlocking the mutex is owner of it
mtx | - mutex to be unlocked |