Explicit locking (by the application programmer)
CICS® provides the following explicit locking commands:
- EXEC CICS ENQ RESOURCE
- EXEC CICS DEQ RESOURCE
These commands can be useful in particular applications in which for example, the installation wants to:
- Protect data that is not automatically protected by CICS; for example, when the data is written into the common work area (CWA).
- Prevent transaction deadlock by locking on records that might be updated by more than one task concurrently.
- Protect a temporary storage queue from being read and updated concurrently.
To be effective, however, all transactions must adhere to the same convention. A transaction that accesses the CWA without using the agreed ENQ and DEQ commands will not be suspended, and protection will be violated. It follows that you will need installation standards.
After a task has issued an EXEC CICS ENQ RESOURCE (data area) command, any other task that issues an EXEC CICS ENQ RESOURCE command with the same data area parameter is suspended until the task issues a matching EXEC CICS DEQ RESOURCE (data area) command, or until the LUW ends, unless the NOSUSPEND option is used.
Note: The concurrent use of locks against more than one resource introduces
the possibility of transaction deadlock.