gtpa2m0cApplication Programming

Messages and Entries

TPF is an operating system in which most units of work are initiated by messages. TPF is a conversational system in that a single response must be provided for each message. The term message applies to the input characters that trigger a work unit.

Entry Control Block

When TPF receives a message or entry into the system, it assigns a storage area called an entry control block (ECB) to that message. The term entry refers to the processing associated with an entry control block. Once activated, TPF processes each entry with equal priority on a first-in, first-out basis. The life of an entry is measured from the creation to the deletion of the entry control block.

An entry in TPF is analogous to a task or process in other operating systems. The ECB, which corresponds to an MVS task control block, is the primary interface between TPF and application programs. The ECB is divided into three parts:

  1. The first part is used for saving such things as registers, PSW, and status. Sections are also reserved for use by application programs and for passing data between the TPF system and application programs.
  2. The second part is protected from use by application programs, and is used by the system for creating and maintaining the ECB address space (the ECB's view of virtual storage). Applications should not attempt to modify this area.
  3. The third part is used by the system to store ECB-based data and tables, such as the macro trace table, and the program nesting area.

The term entry should not be confused with another common TPF term: enter. Enter refers to the use of the TPF enter/back services to transfer control to another program. The entered (or called) program uses the same ECB as the calling program. The fact that both programs use the same ECB means they are part of the same entry.

In the TPF system, programs that use the enter/back services to transfer control to other programs are called E-type or ECB-controlled.

An ENTxC macro transfers processing control to another program segment. This program segment is a processing component of the original entry where the enter macro was invoked.

Each new message causes a program called OPZERO to create a new ECB. There are different OPZERO programs for different message protocols. For example, if the message obeys SNA protocol, the OPZERO appropriate for SNA messages is invoked. The application selection programs of the control program activate the initial segment (also called the root segment) of an application (usually an application input message editor). The application's message editor invokes additional application program segments to process the message. This processing generally involves retrieving information from, or adding information to, the database, and responding to the requesting terminal. During processing, the application programs will make requests of the TPF system programs for services such as input/output, file and main storage allocation, program enters and returns, and release of control.

There is no TPF facility for allocating main storage dynamically. It is fixed at system generation time. Symbolic references and TPF facilities allow common access to the data by any application, and reconfigurations without reprogramming.

Reentrant Programs

As a program attribute, reentrant means that a single program may be used to produce multiple outputs while maintaining the ability to accept additional input prior to producing a previous output. At any given instant, there is a unique ECB, which is referenced by an application program. To be reentrant, the application program must not modify any storage located within the bounds of the program itself. Instead, it must reference switches, indicators or counters in an application work area that is located in the ECB or owned exclusively by the entry. This means that the program may suspend, abort, initiate, or resume processing of any number of entries at any point in their processing, without ever reinitializing. Therefore, one main storage copy of a program, by referring to different ECBs, is equivalent to multiple main storage copies of the program.

An active, assembler application program's dynamic data resides in the current ECB, whose address is, by convention, stored in register 9 (R9). Several TPF macros satisfy the need for data work areas if the work area in the ECB is insufficient. Any such work area is also indirectly referred to through the ECB. Application program segments are assembled in relation to a base address of zero. At execution time, a base register is assigned to the address of the main storage block in which the program segment has been placed. The control program always uses register 8 (R8) as the base register for application program segments.

Reentrancy in ISO-C programs is handled through stack frames. A stack frame is used during the duration of a function. The frame is retained when other functions are called and reused when the called function returns. The stack frames contain the storage required by program variables, unless the variables are declared to be static. Programs that declare data static and modify the static data are said to have "writable static" data. To be reentrant, programs with writable static must specify the RENT parameter when they are compiled.

Therefore, although the terms multijobbing and multitasking are not used in TPF, at any one time many entries may be present in the system (hundreds, perhaps, in large systems), each handling a unique unit of work for any number of applications. Typically, an entry processes one element of input data only. Thus, in contrast to batch-processing jobs, which may run for several hours, an entry is likely to exist only for a few seconds, or even merely a few hundred milliseconds.

Batch type operations may still be handled by TPF in the real-time environment by one of two methods. They may be started by the operator keying an input message at the console, thus causing an entry to be created. A batch of input data, such as a tape file, may be handled by the entry created by operator input. This entry would have a very long life. An alternative method would be to program a monitor that would control the creation of entries, one for each input tape record. When one entry exits, the monitor can create another, thus maintaining a level of activity appropriate to available system resources.