27 #ifndef EMBB_BASE_C_MUTEX_H_ 28 #define EMBB_BASE_C_MUTEX_H_ 30 #include <embb/base/c/internal/platform.h> 31 #include <embb/base/c/errors.h> 32 #include <embb/base/c/atomic.h> 66 #ifdef EMBB_THREADING_ANALYSIS_MODE 72 embb_atomic_int atomic_spin_variable_;
182 embb_spinlock_t* spinlock
200 embb_spinlock_t* spinlock
217 embb_spinlock_t* spinlock,
219 unsigned int max_number_spins
236 embb_spinlock_t* spinlock
249 embb_spinlock_t* spinlock
void embb_spin_destroy(embb_spinlock_t *spinlock)
Destroys a spinlock and frees its resources.
Mutex can be locked only once by the same thread.
Definition: mutex.h:81
opaque_type embb_spinlock_t
Opaque type representing a spinlock.
Definition: mutex.h:60
Mutex can be locked recursively by the same thread.
Definition: mutex.h:83
int embb_spin_lock(embb_spinlock_t *spinlock)
Spins until the spinlock can be locked and locks it.
int embb_mutex_unlock(embb_mutex_t *mutex)
Unlocks a locked mutex.
int embb_mutex_init(embb_mutex_t *mutex, int type)
Initializes a mutex.
int embb_mutex_try_lock(embb_mutex_t *mutex)
Tries to lock the mutex and returns immediately.
int embb_spin_init(embb_spinlock_t *spinlock)
Initializes a spinlock.
int embb_spin_try_lock(embb_spinlock_t *spinlock, unsigned int max_number_spins)
Tries to lock the spinlock and returns if not successful.
int embb_mutex_lock(embb_mutex_t *mutex)
Waits until the mutex can be locked and locks it.
void embb_mutex_destroy(embb_mutex_t *mutex)
Destroys a mutex and frees its resources.
opaque_type embb_mutex_t
Opaque type representing a mutex.
Definition: mutex.h:55
int embb_spin_unlock(embb_spinlock_t *spinlock)
Unlocks a locked spinlock.