Segmentation in Text UI programs and UI programs

Segmentation is tied to the EGL converse statement and the release of system resources. "Converse" here refers to a conversation between a program and a user; the converse statement presents information to the user, waits for a response, then resumes processing with the next instruction.

A nonsegmented program remains in memory while waiting for the user response. A segmented program exits after the converse and reloads after the user responds (except in the IMS™ environment, where the program goes back to read from the message queue after a converse). The idea behind segmentation is to free system resources (such as memory and locked databases) in case the user does not respond immediately.

In general, segmentation issues take center stage in transaction environments like CICS® and IMS. For more information, see Behavior of segmented programs on CICS or IMS. EGL shields you from these implementation issues. With some minor exceptions, you write your code in EGL as if your program is always resident in memory. EGL then generates the appropriate commands for each environment, including extra code to perform the following actions (as needed):

EGL-generated Java™ programs other than UI programs are always nonsegmented and stay resident in memory after a converse. If you are generating programs both in Java and in COBOL, however, there is no harm in declaring the program to be segmented (by setting the program segmented property to YES) or in setting the converseVar.commitOnConverse system variable. This mimics some segmented program behavior in the Java environment, like committing changes to the database and freeing database locks after a converse.

A called program can be segmented. To let EGL know about this, you must set the segmented property to YES for every program in the calling chain.

A nonsegmented program can be easier to code. For example, you do not need to reacquire a lock on an SQL row after a converse. Disadvantages include the fact that SQL rows are held during user think time, a behavior that leads to performance problems for other users who need to access the same SQL row.

Two techniques are available for releasing or refreshing resources before a converse in a non-segmented program:

Compatibility

Table 1. Compatibility considerations for segmented programs
Platform Issue
IMS or CICS for z/OS®
The benefit of using a segmented program on IMS or CICS for z/OS is as follows:
  • In the absence of EGL, the developer of a segmented program writes code to analyze program state at each invocation. With EGL, the application logic is simpler because the developer writes code as if the user were having an ongoing conversation with a program that is always in memory.
  • Limited resources such as memory are used more efficiently so that a larger number of terminals can run EGL programs at the same time.

The benefit of using a non-segmented program on IMS or CICS for z/OS is that the response time for each user is less than for a segmented program because program state is not saved and restored.

An EGL segmented program performs the following actions when the user first invokes it:
  1. Performs initialization tasks, including a determination that the invocation is the user's first
  2. Gives control to the beginning of the program logic
  3. Implements each EGL converse statement in this way:
    1. Uses a work database to save the program state, which is a set of user-specific values that reflect the current status of the user-program conversation. Included is the data for all records and forms. Also included is the information needed to run the program from the appropriate line.
    2. Commits data base and recoverable resources.
    3. Releases all locks.
    4. Does not retain database position, even if the database open statement includes the hold option.
    5. Converses a form.
    6. Ends.
IMS or CICS for z/OS (continued)
When the user performs an action (to update business data, for example), the runtime system restores the program to memory. The program starts from the beginning again. The segmented program automatically performs the following actions:
  1. Performs initialization tasks, including a determination that the invocation is a continuation of processing for this user.
  2. Restores program state, including the data for all forms and records, as well as information about which converse statement ran in the program.
  3. Reads the user's input and performs any edits.
  4. Continues the cycle when implementing the next converse statement:
    1. Saves program state.
    2. Commits database and recoverable resources.
    3. Releases all locks.
    4. Does not retain database position, even if the database open statement includes the hold option.
    5. Converses a form or VGUI record.
    6. Ends.

Feedback