Barrelfish
Functions
event_mutex.c File Reference

Event mutex implementation. More...

Functions

void event_mutex_init (struct event_mutex *em, struct waitset *waitset)
 Initialise a new event mutex.
 
bool event_mutex_enqueue_lock (struct event_mutex *em, struct event_queue_node *qn, struct event_closure lockcont)
 Enqueue a lock acquisition request for the mutex. More...
 
void event_mutex_threaded_lock (struct event_mutex *em)
 Acquire the mutex, blocking the calling thread until done. More...
 
void event_mutex_unlock (struct event_mutex *em)
 Unlock the mutex, which must be held by the caller. More...
 

Detailed Description

Event mutex implementation.

This code implements an event-driven mutex which supports lock acquisition events.

Function Documentation

bool event_mutex_enqueue_lock ( struct event_mutex *  em,
struct event_queue_node *  qn,
struct event_closure  lockcont 
)

Enqueue a lock acquisition request for the mutex.

Parameters
emEvent mutex
qnStorage for queue node. allocated by caller, live until continuation runs
lockcontContinuation for lock acquisition
Returns
true iff the lock was acquired and the continuation run, false if enqueued
void event_mutex_threaded_lock ( struct event_mutex *  em)

Acquire the mutex, blocking the calling thread until done.

Parameters
emEvent mutex
void event_mutex_unlock ( struct event_mutex *  em)

Unlock the mutex, which must be held by the caller.

Note
This always prefers releasing a thread rather than triggering the next event, so threaded code can starve event-driven code in a program that mixes the two models.