User Tools

Site Tools


lock_exclusive_file_access_.htm
Navigation:  Language Reference > 13 - Built-in Functions >====== LOCK (exclusive file access) ====== Previous pageReturn to chapter overviewNext page

LOCK(file [,seconds])

blk2blue.jpg

LOCK Locks a data file.
file The label of a FILE opened for shared access.
seconds A numeric constant or variable which specifies the maximum wait time in seconds.

The LOCK statement locks a file against access by other workstations in a multi-user environment. Generally, this excludes other users from writing to or reading from the file. The file driver may or may not treat separate execution threads within a single program as another workstation or not.

LOCK(file) Attempts to lock the file until it is successful. If it is already locked by another workstation, LOCK will wait until the other workstation unlocks it.
LOCK(file,seconds) Posts the “File Is Already Locked” error after unsuccessfully trying to lock the file for the specified number of seconds.

The most common problem to avoid when locking files is referred to as “deadly embrace.” This condition occurs when two workstations attempt to lock the same set of files in two different orders and both are using the LOCK(file) form of LOCK. One workstation has already locked a file that the other is trying to LOCK, and vice versa. This problem may be avoided by using the LOCK(file,seconds) form of LOCK, and always locking

lock_exclusive_file_access_.htm.txt · Last modified: by 127.0.0.1