PreviousApplication Configuration System Device HandlingNext

Chapter 14: Concurrency Support

The Concurrency support provided with this COBOL system enables several programs to be active at the same time to achieve better use of the Central Processing Unit (CPU) and more sophisticated application programming techniques.

14.1 Overview

The Server Express run-time system provides support for the concurrent operation of run-units. A run-unit consists of your main COBOL program and all the programs or subprograms called by the main program, directly or indirectly. A run-unit, therefore, can be a single program or a suite of programs.

These run-units can communicate with each other using library routines to access a shared memory area. Descriptions of these routines are contained at the end of this chapter.

The concurrency support facility is mapped onto an operating system's process.

14.2 Run-unit Management

When dealing with run-units, you might find it useful to understand the following terminology and concepts:

Term
Description
Originator The first run-unit that makes the call to create a run-unit.
Parent A run-unit that makes the call to create a run-unit.
Child The run-unit created from the call made by the parent.
Coru The set of run-units containing the originator and all descendant run-units.

On creation, the child inherits certain attributes from its parent. The attributes inherited are copies of the parent's attributes at the exact time of the call; any changes made to the parent's attributes after the call are not reflected in the child's attributes. Similarly, any changes made to the child's attributes are not reflected in the parent's attributes.

You should be aware of the following when using run-units:

There are a number of COBOL library routines provided for managing run-units:

Routine
Description
CBL_EXEC_RUN_UNIT Creates an asynchronous COBOL run-unit.
CBL_CULL_RUN_UNITS Clears any dead run-units.
CBL_YIELD_RUN_UNIT Yields the remainder of a run-unit's time-slice.

Full descriptions of these routines are contained in the chapter Library Routines.

14.2.1 Run-unit Intercommunication

Named values and dynamically allocated shared memory provide two means by which run-units can communicate with one another.

Named memory provides a way of passing pointers between different run-units using a name defined at compile time. Named values can be read simultaneously by all units in the coru because the run-time system protects and serializes any updates. The maximum number of named values that can be defined is dependent upon the amount of memory your machine has.

The pointer value could, for example, be a pointer to a block of dynamically allocated memory. Any currently executing run-unit can access this block of memory by simply fetching its address using the name previously assigned. If many run-units wish to alter data in that block of memory, you will need some kind of semaphoring to maintain the integrity of the data.

Shared memory is owned by the coru, so it is freed when the coru terminates. Conversely, non-shared memory is owned by the program that created it, so it is freed when the program is canceled.

The following routines are provided to enable run-units to make use of shared and/or dynamically allocated memory using named values.

Routine
Description
CBL_PUT_SHMEM_PTR Creates or updates a named value.
CBL_GET_SHMEM_PTR Reads a named value.
CBL_ALLOC_MEM Dynamically allocates memory.
CBL_FREE_MEM Frees dynamically allocated memory.

Note: Data is not shared between run-units unless explicitly specified using CBL_GET_SHMEM_PTR and CBL_PUT_SHMEM_PTR


14.3 Run-unit and Memory Routines

The following COBOL system library routines enable you to manage concurrency. See the chapter Library Routines for details of the individual routines.

Memory Allocation:
CBL_ALLOC_MEM Dynamic memory allocation
CBL_FREE_MEM Free dynamically allocated memory
Run-unit Handling:
CBL_CULL_RUN_UNITS Clear dead run-units
CBL_EXEC_RUN_UNIT Create run-unit
CBL_GET_SHMEM_PTR Read named value
CBL_PUT_SHMEM_PTR Create or update named value
CBL_YIELD_RUN_UNIT Yields the remainder of a run-unit's time-slice.


Copyright © 2000 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousApplication Configuration System Device HandlingNext