A simple mutex in C. More...
Go to the source code of this file.
Functions | |
int | mutex_check (MUTEX *mutex_ptr) |
Checks whether a given mutex is locked. | |
void | mutex_lock (MUTEX *mutex_ptr) |
Locks a mutex. | |
void | mutex_unlock (MUTEX *mutex_ptr) |
Unlocks a mutex. |
A simple mutex in C.
Definition in file mutex.c.
int mutex_check | ( | MUTEX * | mutex_ptr | ) |
Checks whether a given mutex is locked.
Non-blocking.
mutex_ptr | A pointer to the mutex. |
Definition at line 47 of file mutex.c.
Referenced by error_occurred(), error_occurred_fiq(), error_occurred_irq(), and mutex_lock().
void mutex_lock | ( | MUTEX * | mutex_ptr | ) |
Locks a mutex.
No other process which requires this mutex may run until the mutex is unlocked. This function will block and wait until the mutex it is trying to lock is free (no other process has a lock on it).
mutex_ptr | A pointer to the mutex. |
Definition at line 25 of file mutex.c.
References mutex_check().
Referenced by error_occurred(), error_occurred_fiq(), and error_occurred_irq().
00025 { 00026 while (mutex_check(mutex_ptr)){} //block until mutex is unlocked 00027 *mutex_ptr = 1; //locked 00028 }
void mutex_unlock | ( | MUTEX * | mutex_ptr | ) |
Unlocks a mutex.
Once a process has finished executing its critical code, it should unlock the mutex to allow other processes to lock it.
mutex_ptr | A pointer to the mutex. |
Definition at line 36 of file mutex.c.
Referenced by error_occurred(), error_occurred_fiq(), and error_occurred_irq().