AMX Event Manager
K
A
DAK
105
7.2 Event Synchronization
The AMX Event Manager supports any number of event groups in a system. Each event
group includes 16 event flags. The maximum number of event groups in a system is
defined in your System Configuration Module (see Chapter 14.5). The defined maximum
sets an upper limit on the number of actual event groups that are available through the
Event Manager in your application.
Each event in a group is represented by a boolean flag representing the state of the event.
The event flags are represented in one 16-bit variable. It is recommended that the
boolean states 0 and 1 be used as false and true indicators respectively. The zero state
therefore represents no event. The one state indicates that the event has occurred.
An event group must be created by an application before it can be used. Restart
Procedures, tasks, ISPs and Timer Procedures can create event groups. It is
recommended that only Restart Procedures and tasks be used for this purpose.
Event Manager procedure ajevcre is used to create an event group. The Event Manager
allocates an event group and returns a group id to the caller. The group id is a handle
which uniquely identifies the particular event group allocated for use by the application.
It is the responsibility of the application to keep track of the group id for future reference
to the event group.
When an event group is created, you can provide a unique 4-character tag to identify the
event group. The tag can be used subsequently in a call to ajevtag to find the event
group id allocated by the Event Manager to the particular event group.
When an event group is created, the caller specifies the initial state that each of the event
flags in the group is to assume. Hence, the process of creating a group automatically
initializes all events in the group to a predefined state. The assignment of events to
specific event flags in the event group is completely determined by the system designer.
Once an event group has been created, it can be used to synchronize tasks to any of the
events which it represents. A task can wait for an event by calling procedure ajevwat.
Only tasks can wait for events. If a task wishes to wait for more than one event, all of the
events must be contained in the one event group specified by the task in its call to
ajevwat.
When the task calls ajevwat to wait for an event, it specifies the group id of the event
group containing the events of interest. It provides a 16-bit mask identifying which of the
events are of interest and a 16-bit value indicating the particular state of interest for each
of the selected events. The task also specifies one of two types of match criterion to be
used for event detection. Tasks can wait for any one of the selected events in the group
to achieve its specified state. Alternatively, the task can insist that all of the selected
events must exactly match their specified state before an event match can be declared.
Finally, the task calling ajevwat must also specify the interval, measured in system ticks,
which it is prepared to wait for the event match to occur. Upon return from ajevwat, the
task receives status indicating whether an event match occurred within the expected time
interval. Note that a task will not be forced to wait if the state of the event flags meets
the task's match criterion at the time of the call.