Chains of Environments and How Environments Are Located - IBM-REXX

As described in previous topics, many language processor environments can be initialized in one address space.A language processor environment is associated with an MVS task. There can be several language processor environments associated with a single task. This topic describes how non-reentrant environments are chained together in an address space.

Language processor environments are chained together in a hierarchical structure to form a chain of environments. The environments on one chain are interrelated and share system resources.For example, several language processor environments can share the same data stack. However, separate chains within a single address space are independent.

Although many language processor environments can be associated with a single MVS task, each individual environment is associated with only one task. Figure below illustrates three language processor environments that form one chain.

Three Language Processor Environments in a Chain

Three Language Processor Environments in a Chain

The first environment initialized was environment 1. When IRXINIT initializes the second environment, the first environment is considered to be the previous environment (the parent environment). Environment 2 is chained to environment 1. Similarly, when IRXINIT initializes the third environment, environment 2 is considered to be the previous environment. Environment 2 is the parent environment for environment 3.

Different chains can exist in one address space.illustrates two separate tasks, task 1 and task 2. Each task has a chain of environments. For task 1, the chain consists of two language processor environments. For task 2, the chain has only one language processor environment.The two environments on task 1 are interrelated and share system resources. The two chains are completely separate and independent.

Separate Chains on Two Different Tasks

Separate Chains on Two Different Tasks

As discussed previously,language processor environments are associated with an MVS task. Under an MVS task, IRXINIT can initialize one or more language processor environments. The task can then attach another task. IRXINIT can be called under the second task to initialize a language processor environment. The new environment is chained to the last environment under the first task. Figure below illustrates a task that has attached another task and how the language processor environments are chained together.

One Chain of Environments For Attached Tasks

One Chain of Environments For Attached Tasks

As shown in above figure, task 1 is started and IRXINIT initializes an environment (environment 1). IRXINIT is invoked again to initialize a second language processor environment under task 1 (environment 2). Environment 2 is chained to environment 1. If you invoke a REXX exec within task 1, the exec runs in environment 2.

Task 1 then attaches another task, task 2. IRXINIT is called to initialize an environment. IRXINIT locates the previous environment, which is environment 2, and chains the new environment (environment 3) to its parent (environment 2). When IRXINIT is called again, IRXINIT chains the fourth environment (environment 4) to its parent (environment 3). At this point, four language processor environments exist on the chain.

Locating a Language Processor Environment

A REXX environment is considered integrated into TSO/E if the address space is a TSO/E address space and the environment has the TSOFL flag set on. Otherwise the environment is not integrated into TSO/E (TSOFL flag off). For the following discussion, a REXX environment that is integrated into TSO/E will be referred to as a ″TSO/E environment″; and a REXX environment that is not integrated into TSO/E will be referred to as a ″non-TSO/E environment.″

Whenever you invoke a REXX exec or routine, the exec or routine must run in a language processor environment. The one exception is the initialization routine, IRXINIT, which initializes environments.

In the TSO/E address space, the system always initializes a default language processor environment when you log on TSO/E and when you invoke ISPF.

If you call a REXX programming routine from TSO/E, the routine runs in the environment in which you called it. If you invoke an exec using the IRXJCL or IRXEXEC routine, a language processor environment may or may not already exist. If an environment does not exist on the

  • Current task (non-TSO/E environment), or
  • Current task or a parent task (TSO/E environment)

the system calls the IRXINIT routine to initialize an environment before the exec runs. Otherwise, the system locates the current non-reentrant environment and the exec runs in that environment.

IRXINIT always locates a previous language processor environment. If an environment does not exist on the current task (TSO/E or non-TSO/E environment) or on a parent task (TSO/E environment only), IRXINIT uses the values in the IRXPARMS parameters module as the previous environment.

A language processor environment must already exist if you call the TSO/E REXX
programming routines IRXRLT, IRXSUBCM, IRXIC, IRXEXCOM, and IKJCT441 or the replaceable routines. These routines do not invoke IRXINIT to initialize a new environment. If an environment does not already exist and you call one of these routines, the routine completes unsuccessfully with a return code.

When IRXINIT initializes a new language processor environment, IRXINIT creates a number of control blocks that contain information about the environment and any REXX exec currently running in the environment. The main control block is the environment block (ENVBLOCK), which points to other control blocks, such as the parameter block
(PARMBLOCK) and the work block extension.

The environment block represents its language processor environment and is the anchor that the system uses on calls to all REXX programming service routines. Whenever you call a REXX programming service routine, you can pass the address of an environment block in register 0 on the call. By passing the address, you can specify in which language processor environment you want the routine to run. For example, suppose you invoke the initialization routine, IRXINIT, in a non-TSO/E address space. On return, IRXINIT returns the address of the environment block for the new environment in register 0. You can store that address for future use. Suppose you call IRXINIT several times to initialize a total of four environments in that address space.

If you then want to call a TSO/E REXX programming service routine and have the routine run in the first environment on the chain, you can pass the address of the first environment’s environment block on the call.You can also pass the address of the environment block in register 0 to all REXX replaceable routines and exit routines. Some service routines also allow the address of the environment block to be passed as a parameter, in place of using register 0. If the parameter is used in these cases, register 0 is ignored.

When a programming service routine is called, the programming service routine must determine in which environment to run. The routine locates the environment as follows:

  1. The routine checks for an environment block parameter (where allowed) or register 0 to determine whether the address of an environment block was passed on the call. If an address was passed, the routine determines whether the address points to a valid environment block. The environment block is valid if:
    • The environment is either a reentrant or non-reentrant environment on the current task (non-TSO/E environment)
    • The environment is either a reentrant or non-reentrant environment on the current task or on a parent task (TSO/E environment).
  2. If the address of a valid environment block was not passed, the routine that is called:
    • Searches for a non-reentrant environment on the current task (non-TSO/E environment). If a non-reentrant environment is found, the routine runs in that environment.
    • Searches for a non-reentrant environment on the current task (TSO/E environment). If a non-reentrant environment is found on the current task, the routine runs in that environment. If a non-reentrant environment is not found on the current task, the parent tasks are searched for a non-reentrant environment. If a non-reentrant TSO/E environment is found on any of these ancestor tasks, the routine runs in that environment.
  3. If the routine could not find a valid environment using the previous steps, the next step depends on what routine was called.
    • If one of the REXX programming routines or the replaceable routines was called, a language processor environment is required in order for the routine to run. The routine ends in error. The same occurs for the termination routine, IRXTERM.
    • If IRXEXEC or IRXJCL were called, the routine invokes IRXINIT to initialize a new environment.
    • If IRXINIT was called, IRXINIT uses the IRXPARMS parameters module as the previous environment.The IRXINIT routine initializes a new language processor environment.

Therefore, IRXINIT does not need to locate an environment in which to run. However, IRXINIT does locate a previous environment to determine what values to use when defining the new environment. The following summarizes the steps IRXINIT takes to locate the previous environment:

  1. If register 0 contains the address of a valid environment block, IRXINIT uses that environment as the previous environment.
  2. If IRXINIT has not yet found an environment to use and a non-reentrant environment exists on the current task, IRXINIT uses the last non-reentrant environment on the task as the previous environment.
  3. If IRXINIT has not yet found an environment to use and this is a request for a TSO/E environment, IRXINIT locates the last non-reentrant environment on the parent tasks. If a non-reentrant TSO/E environment is located on any of the parent tasks, IRXINIT uses it as the previous environment.
  4. If IRXINIT cannot find an environment, IRXINIT uses the values in the default parameters module IRXPARMS as the previous environment.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

IBM-REXX Topics