PURPOSE
To acquire and release a mutual exclusive lock.SYNOPSIS
CALL FMSONE
CALL FMSALL
INPUT PARAMETERS
None.OUTPUT PARAMETERS:
None.DESCRIPTION:
For some applications, the children or parent may need to obtain exclusive use of the data for a short period of time. For example, if the calls to SNAME all passed the same parameters (P1, P2, ...) then the individual copies of SNAME will need to determine what work to do. They might do this by incrementing a shared variable NTASKS to determine their task, MYTASK.
FMS includes a mutual exclusive lock that can be used as follows:
SUBROUTINE SNAME(P1, P2, ...,NTASKS, MAXTSK) INTEGER MYTASK, MAXTSK ... CALL FMSONE MYTASK = NTASKS NTASKS = NTASKS + 1 CALL FMSALL IF(MYTASK .GT. MAXTSK) RETURNThe parent initializes NTASKS to 1. Each child then obtains a unique value of MYTASK that can be use to perform its part of the work. The FMS mutual exclusive lock FMSONE prevents two tasks from reading and incrementing NTASKS at the same time.
If the number of tasks to be performed by subroutine SNAME far exceeds MAXCPU, this method can provide improved load balancing, compared to pre-allocating the work before each call to SNAME. As each task finishes its piece of work, it checks out another piece by incrementing NTASKS. When there is no more work left, it returns.