Task Execution and the TGDA |
DEVELOPER |
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:
Each TGDE and corresponding mapped function parameter must match in type. The length can be different but if it is, truncation of data may occur and the error is detected only at run time. If there is a global element that matches the name in the function external data specification, but the elements do not match in type, PROIV reports an unrecoverable error (invoking rollback if necessary.) The system event log (Unix Syslog and Windows Eventlog) reports a type mismatch or parameter name not found.
If one of the elements is an array but the other is not, or if two arrays do not match in size, PROIV returns an unrecoverable error
If a function formal parameter is not mapped to a TGDA variable, it is demoted to a function local variable. Therefore, as the various Task member functions are executed, each can (under mapping control) read and write to the TGDA under the usage rules outlined above.
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.
Topic ID: 540157