A lock state identifies the use of the object and whether it is shared.
Objects are allocated on the basis of their intended use (read or update) and whether they can be shared (used by more than one job). The file and member are always allocated *SHRRD and the file data is allocated with the level of lock specified with the lock state. The five lock states are (parameter values given in parentheses):
The following table shows the valid lock state combinations for an object:
If One Job Obtains This Lock State: | Another Job Can Obtain This Lock State: |
---|---|
*EXCL | None |
*EXCLRD | *SHRRD |
*SHRUPD | *SHRUPD or *SHRRD |
*SHRNUP | *SHRNUP or *SHRRD |
*SHRRD | *EXCLRD, *SHRUPD, *SHRNUP, or *SHRRD |
You can specify all five lock states (*EXCL, *EXCLRD, SHRUPD, SHRNUP, and SHRRD) for most object types. this does not apply to all object types. Object types that cannot have all five lock states specified are listed in the following table with valid lock states for the object type:
Object Type | *EXCL | *EXCLRD | *SHRUPD | *SHRNUP | *SHRRD |
---|---|---|---|---|---|
Device description | x | ||||
Library | x | x | x | x | |
Message queue | x | x | |||
Panel group | x | x | |||
Program | x | x | x | ||
Subsystem description | x |
It is not an error if the DLCOBJ command is issued against an object where you do not have a lock or do not have the specific lock state requested to be allocated.
You can change the lock state of an object, as the following example shows:
PGM ALCOBJ OBJ((FILEX *FILE *EXCL)) WAIT(0) CALL PGMA ALCOBJ OBJ((FILEX *FILE *EXCLRD)) DLCOBJ OBJ((FILEX *FILE *EXCL)) CALL PGMB DLCOBJ OBJ((FILEX *FILE *EXCLRD)) ENDPGM
File FILEX is allocated exclusively for PGMA, but FILEX is allocated as exclusive-allow-read for PGMB.
You can use record locks to allocate data records within a file. You can also use the WAITFILE parameter on a Create File (CRTF) command to specify how long your program is to wait for that file before a time-out occurs.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.