Internal and External Processes

Up to this point, this section has discussed only cases where an object code file is executed from beginning to end as a single process. However, the system gives you the option of causing individual procedures to be initiated as separate processes. These processes fall into two general categories: internal and external processes.

The following subsections describe the various types of internal and external processes. For a discussion of the varying capabilities of these types of processes, refer to the discussion of inclusion in Understanding Interprocess Relationships.

Internal Processes

Many programming languages give you the ability to create groups of declarations and statements within a program, and to assign a name to each group. In ALGOL, these groupings are referred to as procedures. In WFL, these groupings are referred to as subroutines. However, the basic concept is similar in both cases, and the term “procedure” in this guide refers equally to ALGOL procedures and WFL subroutines.

Other programming languages offer similar types of structures, but ALGOL and WFL are the only languages that give you a choice between the following two methods of invoking a procedure:

  • Procedure entrance

    The syntax for entering a procedure consists of using the procedure name as if it were a statement. Entering a procedure causes the procedure to be executed as part of the same process that invoked the procedure. When the process finishes executing the procedure, the process exits that procedure.

  • Procedure initiation

    The syntax for initiating a procedure consists of using a CALL, PROCESS, or RUN statement in ALGOL, or a PROCESS <subroutine> statement in WFL. Initiating a procedure causes it to be executed as a new process, separate from the process that invoked the procedure. This new process is referred to as an internal process because it is executing part of the same object code file as the initiating process.

Of these methods, procedure entrance has the advantages of simplicity and low impact on system resources, as discussed under Limitations of Tasking later in this section. On the other hand, procedure initiation allows you to use parallel processing or to assign the new process different task attribute values than those of the initiating process. These features are introduced under Advantages of Tasking later in this section.

Note that, if you use the Binder utility to bind a procedure from a subprogram into a host program, that procedure is thereafter considered an internal procedure of the host program. If the host program is an ALGOL program, the host program can either enter or initiate the bound procedure. If the procedure is initiated, the resulting process is considered to be an internal process. For information about the Binder utility, refer to the Binder Programming Reference Manual.

External Processes

An external process is one that results when a statement in a program initiates an external procedure. An external procedure is one that resides in a program other than the program containing the statement that invokes the procedure. External procedures are of three types:

  • Separate programs

    Any program, taken as a whole, can be thought of as an external procedure when it is invoked by a statement in a different program. A separate program is always executed as a separate process; that is, a process can initiate, but cannot enter, a separate program. WFL, ALGOL, and COBOL all allow you to initiate separate programs. In ALGOL and COBOL, you must specify dummy procedures, called declared external procedures, in statements that initiate separate programs.

  • Passed external procedures

    These are procedures passed into the program as parameters. You can write programs in ALGOL that accept procedures as parameters from the initiating program. Statements in the receiving ALGOL program can either enter or initiate a passed procedure.

  • Library procedures

    These are procedures that are provided by a special type of program called a library. Libraries make procedures available for use by other programs. Statements in an ALGOL program can either enter or initiate a library procedure. Programs written in other languages can enter, but cannot initiate, a library procedure. The methods for writing libraries and programs that use libraries are discussed in Using Libraries.