next up previous contents index
Next: Usage Rules Up: Event Library Previous: Type Definitions

Event Operations

 

evSchedule

 

Schedules an event that executes function func with argument arg after delay usec microseconds; usec may equal 0. A handle to the event is returned, and this can be used to cancel the event at some later time. When an event fires, a new thread is created to run function func. Note that even after an event fires and a thread has been scheduled to handle it, the thread does not run until sometime after the currently executing thread gives up the processor. See Section 7 for a description of how threads are scheduled.

Event evSchedule(EvFunc func, void *arg, unsigned usec)

typedef void (*EvFunc)(Event event, void *arg)

Function func must be of type void and take two arguments: the first, of type Event, is a handle to the event itself, and the second, of type void *, is the argument passed to evSchedule. In order to satisfy the C compiler type checking rules when accessing the arguments, function func must begin by casting its second argument to be a non-void type.

evDetach

 

Releases a handle to an event. As soon as func completes, the internal resources associated with the event are freed. All events should eventually be either detached or canceled to assure that system resources are released.

void evDetach(Event event)

evCancel

 

Cancels event and returns EVENT_FINISHED if the event has already happened, EVENT_RUNNING if the event is currently running, and EVENT_CANCELLED if the event has not run and can be guaranteed to not run. In the case where evCancel returns EVENT_RUNNING, the caller must be careful to not delete resources required by the event.

EvCancelReturn evCancel(Event event)

evIsCancelled

 

Returns true if an evCancel has been performed on the event. Because event handlers receive their event as the first calling argument, it is possible for a handler to check for cancellation of itself from other threads.

bool evIsCancelled(Event event)

evDump

 

Displays a ps-style listing of x-kernel threads when the x-kernel is compiled with DEBUG mode. The address of the entry function, the thread state (pending, scheduled, running, finished, or blocked), the time relevant to the thread state, and flags (detached or cancelled), are displayed for each thread controlled by x-kernel monitor. The meaning of the time entry varies according to the state. For pending threads, the time is the time until it will be scheduled; for other states it is the time the thread has spent in that state. The time is reset on each transition, i.e., it is not cumulative.

void evDump(void)



next up previous contents index
Next: Usage Rules Up: Event Library Previous: Type Definitions



Larry Peterson
Tue Jul 1 14:50:34 MST 1997