Application Tasks
K
A
DAK
31
3.5 Task Execution
AMX starts a task by making a FAR procedure call to the task. AMX starts execution of a
task at the task start address specified in the task's definition. The task is started in
response to a request for its execution. Requests can come from Restart Procedures,
tasks, Interrupt Service Procedures or Timer Procedures (see Chapter 3.3).
AMX starts the task when no tasks of higher priority are capable of execution. A task
can therefore only execute if all higher priority tasks are idle or suspended for some
reason.
When AMX starts the task, the following conditions exist:
Interrupts are enabled.
All registers are free for use.
DS,ES DGROUP segment
SS:SP Task stack ready for use
BP Offset of received message on stack
The direction flag is set to forward.
Tasks started in this manner can be readily coded in C or assembler.
A message may have been passed to the task. Message passing is described in more
detail in Chapter 3.9. A task receives message parameters on its stack. The processor
base pointer register (BP) is initialized by AMX to the offset of the first byte of a message
on the task stack.
A caller's message parameters are moved into a message envelope by AMX for
transmission to a task. When the task starts, the parameters in the message envelope are
transferred to the task's stack and the envelope is automatically released for reuse.
The number of parameter bytes that can be passed to a task is configured by you in the
AMX User Parameter Table. The content of the message is completely user defined.
Once a task begins execution, it has complete control of the processor. The interrupt
system must be left enabled to permit device interrupts to be serviced. If a task must
disable interrupts for some reason, it is recommended that this period be kept as short as
possible so that the system's interrupt response time is not degraded.
The application task can execute without concern for the fact that interrupts will occur
and will be serviced. If higher priority tasks become ready for execution, the task will be
suspended temporarily by AMX. When higher priority tasks become suspended or have
completed their operation, the interrupted task will be permitted by AMX to resume
execution from its point of interruption.
Occasionally a task must perform a sequence of operations without interference by other
tasks. If the sequence is too long to permit interrupts to be disabled, the task can request
AMX to become temporarily privileged. During the period of privileged execution,
interrupts remain enabled but execution of any higher priority task, including the AMX
Kernel Task, is inhibited. Privileged operations should be kept as short as possible.