OKL4 Event Server
The OKL4 Event Server is an Async-IPC Multicaster - it allows the specification of an event, the attaching of a number of "listeners" to the event, and the execution of the event via asynchronous IPC, upon which an asynchronous IPC will be sent to all listeners. Its detailed operation is as follows:
- Events are numbered from 1 to MAX_EVENTS (currently 10)
Each event has a linked list of listeners; a listener just contains an L4_ThreadId_t and a notify mask
- A listener registers their interest for a numbered event using register_event (libs/event/event.h), passing the event number and a mask that it wants to receive on notification.
To execute an event, use event_notify, which will L4_Notify the event server with the bit corresponding to the event number switched on. You could also L4_Notify the server yourself with multiple bits switched on to execute multiple events at once.
An async handler is implemented in the event server that receives the notify bitfield. For all bits that are on, the corresponding numbered event is broadcasted to all listeners of that event via an L4_Notify, using the mask set for each listener. For a listener to receive the notify it must obviously have accepted notify messages (using L4_Accept(L4_NotifyMsgAcceptor)) and set an appropriate notify mask (using L4_Set_NotifyMask).
Additionally, other actions can be taken by the event server on the execution of an event, but this is currently coded directly into the event server's async handler. For example, the event server is currently only used to track the primary instance of OK Linux (if there is more than one OK Linux instance running, the "primary" instance is the instance that will receive serial input etc). So, the IDL4 interface of the event server is extended to provide a function that will return the primary instance, and a function that will register new instances, and on receiving a switch event the event server switches the primary instance.
To check out how that all works have a look at iguana/event/src/main.c and libs/event/include/interfaces/event.idl4.