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

SPT_LOCKREC(2) OSS System Calls Reference Manual
Structured files
Calling LOCKREC after positioning on a nonunique key
If the call to SPT_LOCKREC( ) immediately follows a call to
KEYPOSITION where a nonunique alternate key is specied,
the call to SPT_LOCKREC() fails. A subsequent call to the
Guardian FILE_GETINFO_ or FILEINFO procedure shows that
a Guardian le-system error 46 (invalid key) occurred.
However, if an intermediate call to SPT_READX() is per-
formed, the call to SPT_LOCKREC() is permitted because a
unique record is identied.
Current-state indicators after SPT_LOCKREC()
After a successful call to SPT_LOCKREC( ), current-state indi-
cators are unchanged.
Unstructured files
Locking the relative byte address (RBA) in an unstructured file
Record positions in an unstructured le are represented by an
RBA, and the RBA can be locked with SPT_LOCKREC().To
lock a position in an unstructured le, rst call the Guardian
POSITION procedure with the desired RBA, and then call
SPT_LOCKREC(). This locks the RBA; any other process
attempting to access the le with exactly the same RBA
encounters a record is locked condition. You can access
that RBA by positioning to RBA-2. Depending on the processs
locking mode, the call either fails with Guardian le-system
error 73 (record is locked) or is placed in the locking
queue.
Record pointers after a call to SPT_LOCKREC()
After a call to SPT_LOCKREC( ), the current-record, next-
record, and end-of-le pointers remain unchanged.
Ways to avoid or resolve deadlocks
One way to avoid deadlock is to call function 4 of the
SPT_SETMODE() procedure to establish one of the alternate
locking modes. A common method of avoiding deadlock situa-
tions is to lock records in some predetermined order. Deadlocks
can be resolved if you lock records using a nowait open and call
the Guardian AWAITIO procedure with a timeout specied.
Use on OSS Objects
This procedure operates only on Guardian objects. If an OSS le is specied, Guardian le-
system error 2 occurs.
RETURN VALUES
The SPT_LOCKREC() function returns 0 (zero) upon successful completion. Otherwise, this
function returns a nonzero Guardian le-system error number that indicates the outcome of the
operation.
For information about Guardian le-system error numbers, see the Guardian Procedure Errors
and Messages Manual.
7208 Hewlett-Packard Company 527186-007