Standards / Extensions | C or C++ | Dependencies |
---|---|---|
Language Environment | C only |
#include <mtf.h>
int tsched(int task_id, const char *func_name, …);
The tsched() built-in library function is used to schedule parallel functions under MVS.
The tsched() library function schedules a parallel function (func_name) to be executed in a subtask that has been attached and initialized by tinit(). The first argument task_id can be used to specify the task where the parallel function is to be executed. The task_id can be set to MTF_ANY to indicate that the parallel function can be run in any task or, task_id can be set to a specific task number between 1 and the number of subtasks specified on tinit().
The tsched() function allocates approximately 2K of space as a work area. This work area is not freed. However, a call to the tsyncro() function will make work areas previously allocated by tsched() available for reuse by tsched(). Because tsched() does not free the work area storage, it is possible the tsched() will cause an application Short on Storage condition to occur if enough calls are made to the tsched() function.
You can call tsched() from your main C task as often as necessary to schedule parallel functions for execution. If all of the subtasks are busy running previously scheduled functions, each call in excess of the number of subtasks will cause func_name to be run after previously scheduled functions in the first qualifying subtask that becomes available.
All scheduled functions must be computationally independent. A function cannot use variables that are modified by another scheduled function or the scheduling function. To determine if all other scheduled functions have completed, use the tsyncro() library function (see tsyncro() — Wait for MTF subtask termination).
The name of the parallel function, func_name, must not be longer than 8 characters. If it is, the name will be truncated to the first 8 characters with no warning.
Usually tsched() returns to the calling main task program before the scheduled parallel function has completed execution. Therefore, you must call tsyncro() to ensure that your parallel functions have completed execution.
If tinit() has not been successfully called before tsched(), tsched() indicates that MTF is inactive.
If tinit() is called by a program running under IMS, CICS, or DB2, the request will not be processed and the returned value will indicate that MTF calls are not supported under these systems.
If successful, scheduling the parallel function for execution in a subtask, tsched() returns MTF_OK.