## 11.3.4 LOCKON and LOCKOFF Directives (VAX only)

The LOCKON and LOCKOFF directives enclose a region of executable code within a parallel DO-loop. In effect, these directives force processes to execute this critical region one at a time by excluding all other processes from the region while one process is executing it.

A process executing the critical region "has the lock" while other processes that want to execute it must wait until it is free. The lock becomes free when the process in the critical region executes the associated LOCKOFF directive.

The LOCKON and LOCKOFF directives take the following forms:

    cPAR$ LOCKON lck-var

       critical region

    cPAR$ LOCKOFF lck-var

c
  Is the letter or character that introduces the directive tag (see Section 11.1).
lck-var
  Is a LOGICAL*4 variable that can be any of the following items:

  - Scalar variable

  - Dummy argument

  - Record field

  - Array element

  The lock variable (lck-var) must be in a shared common block or a variable declared as CONTEXT_SHARED in the routine containing a parallel DO-loop.

The lock variable is considered locked when it has a value of .TRUE. and free when it has a value of .FALSE.

Rules and Behavior

All LOCKON directives require an associated LOCKOFF directive that executes in the DO-loop.

Statements in critical regions cannot transfer control outside the region.

Lock variables can only have a LOGICAL*4 data type. Other data types cause a compilation error.

Lock variables must be shared, either by specification or default. If they are declared private, a compilation error results.

For More Information:

For details on how to use the LOCKON and LOCKOFF directives, see Example 11-1 and your user manual.

Previous Page Next Page Table of Contents