Using Task Attributes

Certain task attributes exist only for the purpose of transmitting information between different members of a process family. These attributes have no meaning to the system, and thus can be used only for storing values to be read later. The following are the task attributes that fall into this category:

  • AX

    This attribute stores a string that the process can read with an ACCEPT statement.

  • LOCKED

    This Boolean-valued task attribute accesses the availability state of an event. For further information, refer to Using Implicitly Declared Events in Using Events and Interlocks. For information about using this attribute to control a task from a job, refer to Controlling a Task from a Job in Tasking from Programming Languages.

  • SW1 through SW8

    Each of these attributes stores a Boolean value.

  • TARGET

    This attribute stores an integer value.

  • TASKSTRING

    This attribute stores a string value.

  • TASKVALUE

    This attribute stores a real value.

In a more general way, all task attributes are instruments for interprocess communication (IPC). After all, each task attribute stores information about the process it applies to, and this information is visible to any other process that can access the task variable. What distinguishes the task attributes in the preceding list is that they have no meaning at all, except what is established by convention between two processes.

These task attributes provide the simplest means of IPC. There is no need to create and define complex data structures, as all task attributes are predeclared.

Each of the attributes involved stores only a single Boolean, arithmetic, or string value, which can be changed and read repeatedly during process execution.

A disadvantage to using these task attributes is that the task attribute names are fixed and thus do not convey any information about what is being stored in the attribute. Someone reading the program might have trouble understanding why the attribute is being used. By contrast, a variable can always be assigned a meaningful name.

Another disadvantage is that it generally takes more processor time to read or write a task attribute than to read or write variables declared by the process.

For two processes to communicate using task attributes, one or both must have access to a common task variable. If two processes belong to the same process family, they can always communicate by way of the MYJOB task variable. If two processes have a common parent, they can communicate by way of their own EXCEPTIONTASK task attribute. For further information about the task variables a process can access, refer to Understanding Interprocess Relationships.

The task attribute most commonly used for IPC is TASKVALUE, and its most common use is in task equations. For example, you could use TASKVALUE to instruct a program whether to produce a printout. The program could contain the following statement:

IF MYSELF.TASKVALUE = 1 THEN F.KIND:= VALUE(PRINTER)
   ELSE F.KIND:= VALUE(REMOTE);

If TASKVALUE has a value of 1, the program produces a printout; otherwise the program displays its output at the user's terminal. You might use a statement like the following to initiate the program and cause the program to produce a printout:

RUN REPORT/GENERATOR;TASKVALUE = 1