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

System Functions (s and S) SPT_LOCKREC(2)
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 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 use one of the alternate locking
modes that can be established by function 4 of the
SPT_SETMODE() procedure. A common method of avoiding
deadlock situations 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.
ERRORS
None. This function does not set the errno variable.
RELATED INFORMATION
Functions: SPT_CANCEL(2), SPT_CONTROL(2), SPT_FILE_CLOSE_(2),
SPT_FILE_OPEN_(2), SPT_LOCKFILE(2), SPT_READLOCKX(2),
SPT_READUPDATELOCKX(2), SPT_READUPDATEX(2), SPT_READX(2),
SPT_SETMODE(2), SPT_UNLOCKFILE(2), SPT_UNLOCKREC(2),
SPT_WRITEREADX(2), SPT_WRITEUPDATEUNLOCKX(2),
527186-005 Hewlett-Packard Company 7205