32
K
A
DAK
Application Tasks
3.6 Task and Event Synchronization
AMX offers several simple forms of task/event synchronization.
Using the ajwait call, a task can unconditionally wait for an event. The event can be
task dependent, device dependent or time dependent. The task, having issued an ajwait
call, remains suspended unconditionally until another task, an Interrupt Service Procedure
or a Timer Procedure issues an ajwake call requesting AMX to wake up the particular
waiting task. This ajwait/ajwake pair can be used to provide simple event
synchronization.
AMX also supports this form of synchronization with an automatic timeout facility. A
task can issue an ajwatm call specifying the maximum interval which the task is willing
to wait for the event to occur. If no other task, ISP or Timer Procedure issues an ajwake
call in the interim, AMX will automatically wake up the task when the interval expires.
The task receives from AMX an indication whether or not a timeout occurred.
A more powerful and flexible form of task/event synchronization is supported by task
signals. Each task owns a set of 15 user defined task signals. A task can issue an
ajsgwat call to wait, with optional timeout, for a specific combination of signals to be
set.
Tasks, ISPs and Timer Procedures can call AMX procedure ajsgnl to set any of a
particular task's task signals when corresponding events are detected. The task receives
an indication whether or not a timeout occurred.
A task can also be synchronized to another task using the AMX call and wait message
passing facilities. A task sends a message to another task using the AMX ajsenw call
which forces the sender to wait. When the receiving task eventually receives the sender's
message, it can issue an ajwakc call to wake the calling task. The sender will then
resume execution knowing full well that its message has already been received by the
task to which it was sent. If the receiving task does not issue an ajwakc call, AMX will
do so automatically when the receiving task ends. No timeout is provided with this type
of synchronization.
These synchronization facilities offer the advantage of simplicity. These mechanisms are
an inherent part of the AMX kernel. The disadvantage of each is that the event signaller
must know the task id of the task which is waiting or to whom a message must be sent.