Guardian Procedure Calls Reference Manual
LOCKFILE Procedure
Summary
Syntax for C Programmers
Syntax for TAL Programmers
Parameters
Condition Code Settings
Considerations
OSS Considerations
Related Programming Manual
Summary
The LOCKFILE procedure is used to exclude other users from accessing a file (and any records
within that file). The "user" is defined either as the opener of the file (identified by filenum) if the
file is not audited—or the transaction (identified by the TRANSID) if the file is audited.
If the file is currently unlocked or is locked by the current user when LOCKFILE is called, the file
(and all its records) becomes locked, and the caller continues executing.
If the file is already locked by another user, behavior of the system is specified by the locking
mode. There are two "locking" modes available:
• Default—Process requesting the lock is suspended (see Considerations).
• Alternate—Lock request is rejected with file-system error 73. When the alternate locking mode
is in effect, the process requesting the lock is not suspended (see Considerations).
NOTE: The LOCKFILE procedure performs the same operation as the FILE_LOCKFILE64_ Procedure
(page 450), which is recommended for new code.
Key differences in FILE_LOCKFILE64_ are:
• The tag parameter is 64 bits wide.
• The procedure returns an error code value rather than a condition code, simplifying
error-handling code.
Syntax for C Programmers
#include <cextdecs(LOCKFILE)>
_cc_status LOCKFILE ( short filenum
,[ __int32_t tag ] );
• CEXTDECS (through the included file TNSINTH) defines 32-bit values as the typedef
__int32_t, which for TNS and TNS/R compiles is defined as long and for TNS/E compiles
is defined as int.
• The function value returned by LOCKFILE, which indicates the condition code, can be interpreted
by _status_lt(), _status_eq(), or _status_gt() (defined in the file tal.h).
Syntax for TAL Programmers
CALL LOCKFILE ( filenum ! i
,[ tag ] ); ! i
768 Guardian Procedure Calls (L)