When a Task is executed, the actual parameters (supplied by the caller) that have In and Both usage are each loaded into their own section of the Task Global Data Area (TGDA). Sections of the TGDA reserved for Out parameters and Global data elements are initialised to nulls. The Task Entry function is then loaded into the Task.

When a function is loaded into a Task, the kernel checks the list of variables in the function's parameter list against the list of mapped variables for that function. If a function parameter is not mapped to a Global data element or a Task parameter, the function will treat that variable as a local (scratch) variable for the execution of the function in that Task. This is important to note, as it is quite possible (and legal) to use the same function in many Task lists, but have different mapping of function parameters each time. You do not have to map every function parameter to a variable in the TGDA for every function’s appearance in every Task’s member function list.

The kernel also does a number of runtime checks on mapped data elements when it loads a function into the Task at runtime:

It is important to note that what is returned to the calling application is defined by the specification of the Task parameters, not of any function parameter. Only Task parameters defined as Out or Both are returned to the caller. Parameters with other usage are not  returned.

Function parameters, on the other hand, control what is written to the TGDA. Only function parameters defined as Out or Both update the TGDA. A mapped function parameter’s storage area is local to the function (in function data space), not in the TGDA. The usage of the mapped function parameter determines whether the value of the Task parameter or Global data element (to which the function parameter is mapped) is copied into this function local storage when the function starts executing. This happens in all cases but Out usage. The usage also determines whether the final value in the function local storage is copied to the mapped-to Task parameter’s (or Global data element’s) storage area in the TGDA at the end of the function’s execution. This happens in all cases except In usage.

Comment on this topic

Topic ID: 540157