Barrelfish
Functions
waitset.c File Reference

Waitset and low-level event handling mechanism. More...

Functions

void waitset_init (struct waitset *ws)
 Initialise a new waitset.
 
errval_t waitset_destroy (struct waitset *ws)
 Destroy a previously initialised waitset.
 
void poll_channels_disabled (dispatcher_handle_t handle)
 Check polled channels.
 
errval_t get_next_event_disabled (struct waitset *ws, struct waitset_chanstate **retchannel, struct event_closure *retclosure, struct waitset_chanstate *waitfor, struct waitset_chanstate *waitfor2, dispatcher_handle_t handle, bool debug)
 Get next pending event. More...
 
errval_t get_next_event (struct waitset *ws, struct event_closure *retclosure)
 Wait for (block) and return next event on given waitset. More...
 
errval_t event_dispatch (struct waitset *ws)
 Wait for (block) and dispatch next event on given waitset. More...
 
errval_t wait_for_channel (struct waitset *ws, struct waitset_chanstate *waitfor, errval_t *error_var)
 Dispatch events until a specific event is received. More...
 
errval_t event_dispatch_non_block (struct waitset *ws)
 check and dispatch next event on given waitset More...
 

Detailed Description

Waitset and low-level event handling mechanism.

A "wait set" is a collection of channels to wait on, much like an FDSET in POSIX. There should be a default, static wait set for each dispatcher. Threads which wait for events specify the wait set they are waiting on.

Function Documentation

errval_t event_dispatch ( struct waitset ws)

Wait for (block) and dispatch next event on given waitset.

Wait until something happens, either activity on some channel, or deferred call, and then call the corresponding closure.

Parameters
wsWaitset
errval_t event_dispatch_non_block ( struct waitset ws)

check and dispatch next event on given waitset

Check if there is any pending activity on some channel, or deferred call, and then call the corresponding closure.

Do not wait! In case of no pending events, return err LIB_ERR_NO_EVENT.

Parameters
wsWaitset
errval_t get_next_event ( struct waitset ws,
struct event_closure *  retclosure 
)

Wait for (block) and return next event on given waitset.

Wait until something happens, either activity on some channel, or a deferred call, and then return the corresponding closure. This is the core of the event-handling system.

Parameters
wsWaitset
retclosurePointer to storage space for returned event closure
errval_t get_next_event_disabled ( struct waitset ws,
struct waitset_chanstate **  retchannel,
struct event_closure *  retclosure,
struct waitset_chanstate waitfor,
struct waitset_chanstate waitfor2,
dispatcher_handle_t  handle,
bool  debug 
)

Get next pending event.

Check if there is a pending event that matches current thread and return it. Pending events are in a pending queue and in a waiting queue. A pending event then will be removed from a pending/waiting queue and become unregistered or, if it's persistent, will be re-registered to an idle queue or a polled queue (UMP channels) of a waitset. If there's no pending event, block this thread. If there's a pending event but it doesn't match our thread, don't remove it from a pending queue and wake up a matching thread. If there's no matching thread, add it to a waiting queue.

Parameters
wsWaitset with sources of events
retchannelHolder of returned event
retclosureHolder of returned closure
waitforSpecific event that we're waiting for (can be NULL)
handleDispatcher's handle
debugDebug mode (not used)
errval_t wait_for_channel ( struct waitset ws,
struct waitset_chanstate waitfor,
errval_t *  error_var 
)

Dispatch events until a specific event is received.

Wait for events and dispatch them. If a specific event comes, don't call a closure, just return.

Parameters
wsWaitset
waitforEvent, that we are waiting for
error_varError variable that can be changed by closures