<< Back to Codezero API Reference
int l4_mutex_control(void *mutex_word, int op);
op argument defines whether the operation is a lock or unlock operation.
mutex_word argument specifies the userspace virtual address for the lock.
Mutexes are locked and unlocked with no system call assistance if there is no lock contention.
If a lock contention occurs, lock holder and lock contender synchronize by the assistance of this system call.
In its current state this system call represents a *binary semaphore* implementation.
#define L4_MUTEX_LOCK 0
#define L4_MUTEX_UNLOCK 1
struct l4_mutex {
unsigned int lock;
} __attribute__((aligned(sizeof(int))));
void l4_mutex_init(struct l4_mutex *m);
int l4_mutex_lock(struct l4_mutex *m);
int l4_mutex_unlock(struct l4_mutex *m);
l4_mutex_init() initializes an uninitialized mutex.
l4_mutex_lock() locks an initialized, mutex. If it contends, it calls the mutex syscall.
l4_mutex_unlock() releases an acquired mutex. If there was contention, mutex syscall is called to resolve by the kernel.