AMX Event Manager
K
A
DAK
103
7. AMX Event Manager7.1 Introduction
The AMX Event Manager provides the most general form of event synchronization
offered by AMX. The Event Manager provides a convenient mechanism for separating
the tasks waiting for events from the tasks, Timer Procedures and Interrupt Service
Procedures which can signal the event. The Event Manager also allows more than on e
task to simultaneously wait for a particular event. Tasks can wait for a particular
combination of events or for any one of a set of events to occur.
The Event Manager provides a set of event flags which can be associated with specific
events in your system. These event flags are provided in groups with 16 event flags per
group. Note that the number of event flags per group is dictated by the basic register
width (integer size) of the target processor. Hence, 32-bit versions of AMX have 32
event flags per group.
As an example, suppose that two tasks, A and B, must each wait until a motor turns on.
Assume that an interrupt will occur when the motor is turned on.
It is assumed that Tasks A and B are completely independent; their processing is
unrelated. One method of accomplishing the necessary synchronization is for both tasks
to set software flags indicating that they are waiting for the motor and then call AMX
procedure ajwait to wait for the motor to turn on. When the motor control ISP detects
that the motor has started, it could check the wait flags for the two tasks and wake the
tasks if necessary with calls to ajwake.
This solution does not provide good functional separation between processes. The motor
control ISP must be aware that Tasks A and B are waiting for the motor to turn on. As
you can imagine, this lack of functional separation is compounded when there are many
types of events occurring in a system.
The Event Manager provides a more general solution to this problem. An event flag is
defined to represent the state of the motor (off or on). A Restart Procedure initializes the
event flag so that it matches the actual state of the motor. When Tasks A and B must
wait for the motor, they do so by calling the Event Manager requesting to wait until the
motor control event flag indicates that the motor is on. When the motor control ISP
detects that the motor is on, it signals the event with a call to the Event Manager. The
Event Manager wakes all tasks, including Tasks A and B, which are waiting for the
motor to be on.