new_mutex

NAME
SYNOPSIS
DESCRIPTION
BUGS
AUTHOR
LICENSE
VERSION

NAME

new_mutex, mutex_enter, mutex_leave, mutex_try_enter - mutual exclusion (mutex) locks

SYNOPSIS

#include <pthr_mutex.h>

mutex new_mutex (pool);
void mutex_enter (mutex, pseudothread);
void mutex_leave (mutex, pseudothread);
int mutex_try_enter (mutex, pseudothread);

DESCRIPTION

Mutex locks are simple: at most one pseudothread may enter the critical area protected by the lock at once. If instead you wish multiple reader / single writer semantics, then please see new_rwlock(3).
Mutex locks are automatically released if they are being held when the thread exits.
Note that there are possible deadlocks when using locks. To avoid deadlocks, always ensure every thread acquires locks in the same order.
new_mutex creates a new mutex object.
mutex_enter and mutex_leave enter and leave the critical section. Only one thread can run at a time inside the critical section.
mutex_try_enter is identical to mutex_enter except that it does not block if the lock is held by another thread. The function returns true if the lock was successfully acquired, or false if another thread is currently holding it.

BUGS

A common mistake is to accidentally call mutex_leave when you are not holding the lock. This generally causes the library to crash.

AUTHOR

Richard Jones <rich@annexia.org>

LICENSE

GNU LGPL (see http://www.gnu.org/)

VERSION

pthrlib-3.0.3