Multithreading facility

A PL/I program is a set of one or more procedures. The program normally executes as a single execution unit, or as part of a single execution unit. When a procedure invokes another procedure, control is passed to the invoked procedure, and execution of the invoking procedure is suspended until the invoked procedure passes control back. This execution with a single flow of control is synchronous flow.

When using the PL/I multithreading facility, the invoking procedure does not relinquish control to the invoked procedure. Instead, an additional flow of control is established so that both procedures are executed concurrently. The execution of such concurrent procedures is called asynchronous flow.

The PL/I multithreading facility allows the execution of parts of a PL/I program asynchronously in multiple threads. A thread is a unit of work that competes for the resources of the computing system. A thread is not the equivalent of a task in OS PL/I. Except for the main thread in a program, a thread is always independent of and unrelated to other threads in the program. When a procedure invokes another procedure as a thread, this action is known as attaching, or creating the thread.

Execution of one or more threads occurs in a process, which can be thought of as a PL/I program. PL/I does not provide the capabilities to create and manage multiple processes or tasks, but it does allow creation and management of multiple threads in a single program (process).

There is normally one application thread per process. Multiple threads can be attached (created) to:
  • Perform a piece of work in a shorter elapsed time. Such applications can be batch applications that are not interacting with the user. For example, one procedure could attach a thread which would compile a PL/I program.
  • Perform high response parts of a program in one thread and I/O parts in another thread, and typical response parts in a third.
  • Use computing system resources that might be idle. These resources can include I/O devices as well as the CPUs.
  • Implement real-time multi-user applications where the response time is critical.
  • Isolate independent pieces of work for reliability. That is, the failure of a part of a job can be isolated while other independent parts are processed.
Note: Operating system services must not be directly used when PL/I provides the appropriate function.