26
K
A
DAK
Application Tasks
Tasks which do not receive messages are written as Large or Medium model C functions
without formal parameters. These tasks must be started using AMX procedure ajtrig.
For this reason, such tasks are called trigger tasks. For example, a task that immediately
ends would appear as follows:
void cdecl task1(void)
{}
Tasks which must receive a message are written as Large or Medium model C functions
which receive a set of parameters. Tasks that receive messages are called message tasks.
These tasks must be started using any of the variations of AMX procedure ajsend or
ajsenw. For example, a task which receives an integer as a message and then ends would
appear as follows:
void task2(int message)
{}
A message task must be defined to include one to four message queues (also called task
mailboxes) in which the task receives messages. Messages which arrive in the task's
mailboxes are automatically delivered to the task on the task's stack ready for processing
by the task. This type of message processing is described in Chapter 3.9.
Tasks written in assembly language must be coded as FAR procedures as follows:
TASK_CODE SEGMENT BYTE 'CODE'
;
; The task is located in user program memory
;ASSUME CS:TASK_CODE
;
STTASK PROC FAR
:
Set DS and ES if required by task
Access parameter on stack via BP
Do task functions
:
RET ;Return to AMX
;
STTASK ENDP
;
TASK_CODE ENDS