StackThreads/MP: version 0.77 User's Guide
int st_mutex_init(m); @ int st_mutex_trylock(m); @ int st_mutex_lock(m); @ int st_mutex_unlock(m); @ int st_mutex_destroy(m); @ st_mutex_t * m; @ st_mutex_t x = ST_MUTEX_INITIALIZER;
Mutex is an essentially a binary semaphore with upper limit 1 (a
semaphore that can only have 0 or 1 as its value). The mutex is either in
locked or unlocked state. st_mutex_init(m)
initializes it to
an unlocked state. st_mutex_lock(m)
waits for m to become
unlocked and lock it. st_mutex_trylock(m)
behaves like
st_mutex_lock(m)
, except that it immediately returns value
ST_BUSY
when m is locked. st_mute_unlock(m)
unlocks m. It signals an error if m is not
locked. st_mutex_destroy(m)
destroys m. It signals an
error if m is locked. st_mutex_t x = ST_MUTEX_INITIALIZER
defined a global or static mutex.