9 Receipt of messages from other tasks

Suppose that your task is controlling other tasks. Say it sends an OBEY message to some other task. The other task will carry out its operations, maybe generating output intended for the user to see, and send your task a final message when it has completed the obey. You can use:

  TASK_ADD_MESSINFO(PATH,MESSID,STATUS)

to tell the fixed-part you are expecting messages on this PATH,MESSID combination, then return to the fixed-part having set a request ACT__MESSAGE. You could also have set a timeout as above. You can use multiple calls to TASK_ADD_MESSINFO if you are controlling more than one operation in other tasks.

When the fixed-part calls your application again, you can use:

  TASK_GET_MESSINFO(PATH,CONTEXT,NAME,VALUE,MESSID,EVENT,STATUS)

to obtain the information carried in the message.

Note that any output generated by the other task (e.g. using MSG_OUT) will have been handled automatically by the fixed-part of your task and will not cause your application subroutine to be called. Messages from subsidiary tasks which do cause your subroutine to be called will generally be completion messages, however, a special ‘TRIGGER’ message is also available.

To send a TRIGGER message the subsidiary task can use:

  TASK_TRIGGER(ACTNAME,VALUE,STATUS)

The message will be sent and the task can continue working.

When your controlling task calls TASK_GET_MESSINFO, MESSYS__TRIGGER will be returned in EVENT.

Obviously, the example for all this is rather complex, involving three separate tasks and multiple actions. The example, written by William Lupton, involves a pair of tasks for making tea and coffee respectively and a third task controlling them, and is relegated to Appendix A.