ECROS API Function OsAcceptEvents()

OsEventsT OsAcceptEvents( OsEventsT events );

Function OsAcceptEvents() must be called by the client application to accept and clear events in the currently running task.  The function argument is the pattern of events to be accepted and cleared.  This is the only means provided in the API to clear events.  The function returns the events that were set both in the function argument and the running task's event pattern.  These are the events that have been cleared in the running task by the function call.  The term "accepting" events is intended to signify the combination of looking at them and clearing them.  Using this function, the client selects a pattern of events to look at, those that were set appear in the result and are then clear.  If a different way of looking at events is chosen, using the argument of the task function or a different API function, the returned value of OsAcceptEvents() will typically be discarded.

Example

The example below shows part of a task function that processes one of three events each time it runs.  Function OsAcceptEvents() is used to look for each event in the task's event pattern in turn.  If the event is set, the function returns the event, which is non-zero, and the block that processes the event executes.  The event has been cleared.  If more than one event is set, the task will still be ready upon return and ECROS will re-queue it.  Higher priority tasks and other ready tasks of the same priority have a chance to run before this task runs again.  This is a good way to make sure a task does not "hog" the CPU.


Last edited December 10, 2002.  All material Copyright © 2002 Graham Davies, ECROS Technology.