Open System Services System Calls Reference Manual (G06.28+, H06.05+)

SPT_LOCKFILE(2) OSS System Calls Reference Manual
Nowait and SPT_LOCKFILE()
If the SPT_LOCKFILE() function is used to initiate an operation with a le
opened for nowait I/O, it must complete with a corresponding call to the Guar-
dian AWAITIO procedure.
Locking modes
Default mode If the le is already locked by another user when
SPT_LOCKFILE() is called, the process requesting the lock is
suspended and queued in a locking queue behind other users try-
ing to access the le. When the le becomes unlocked, the user
at the head of the locking queue is granted access to the le. If
the user at the head of the locking queue is requesting a lock, the
user is granted the lock and resumes execution. If the user at the
head of the locking queue is requesting a read, the read opera-
tion continues to completion.
Alternate mode If the le is already locked by another user when the call to
SPT_LOCKFILE() is made, the lock request is rejected, and
the call to SPT_LOCKFILE() completes immediately with
Guardian le-system error 73 (file is locked). The alter-
nate locking mode is specied by calling the
SPT_SETMODE() procedure and specifying function 4.
Locks and open files (applies to nonaudited files only)
Locks are granted on a le open (that is, on a le number) basis. Therefore, if a
process has multiple opens of the same le, a lock of one le number excludes
access to the le through other le numbers.
Attempting to read a locked file in default locking mode
If the default locking mode is in effect when a call to SPT_READX( ) or
SPT_READUPDATEX() is made for a le that is locked by another user, the
caller of SPT_READX() or SPT_READUPDATEX() is suspended and queued
in the locking queue behind other users attempting to access the le.
For nonaudited les, a deadlock condition (a permanent suspension of your
application) occurs if SPT_READX() or SPT_READUPDATEX() is called by
the process that has a record locked with a le number other than that supplied in
the SPT_READX() or SPT_READUPDATEX() call. For an explanation of
multiple opens by the same process, see the SPT_FILE_OPEN_(2) reference
page either online or in the Open System Services System Calls Reference
Manual.
Accessing a locked file
If the le is locked by a user other than the caller at the time of the call, the call
is rejected with Guardian le-system error 73 (file is locked) when:
SPT_READX( ) or SPT_READUPDATEX() is called, and the alternate lock-
ing mode is in effect.
SPT_WRITEX(), WRITEUPDATE, or SPT_CONTROL() is called.
A count of the locks in effect is not maintained. Multiple locks can be unlocked with one call to
SPT_UNLOCKFILE().
7204 Hewlett-Packard Company 527186-007