APLX Help : Help on APL language : System Functions & Variables : ⎕NLOCK Lock/Unlock native file
|
|
![]() |
|
The The syntax of ⎕NLOCK TIE, MODE {,COUNT {,STARTBYTE {,TIMEOUT}}} TIE specifies the file to lock or unlock MODE specifies the lock operation to perform, as follows: 0 - unlock file or segment 1 - establish a read lock on a file or segment 2 - establish a write lock on a file or segment COUNT specifies the length in bytes of the segment to lock or unlock. The
default value of STARTBYTE specifies the offset from the start of the file at which the lock
segment begins. A value of TIMEOUT is used to specify a request timeout value in milliseconds (see
below). A value of The implementation of Two lock modes are supported. A read lock prevents other users from write- locking the file or segment. A write lock prevents other users from read-locking or write-locking the file or segment. An attempt to use Using Locking a segment which is already locked by the user causes the old lock type to be removed and the new lock type to take effect. Changing or unlocking a portion from the middle of a larger locked segment leaves a smaller segment at either end. The TIMEOUT parameter is used to specify a timeout value for the lock request. If the requested lock cannot be immediately granted because another user has locked the segment in an incompatible mode, the process will sleep for TIMEOUT milliseconds waiting for the segment to become free. If a TIMEOUT value of 0 is specified, the lock request will give an error immediately if the lock cannot be granted. A value of The host locking mechanism detects deadlock situations. If a lock request cannot be immediately granted because another process has the segment locked, and the other process is sleeping on a request for a segment which the user has locked, the potential for a deadlock exists. In this case the requested lock will be refused. Note however that deadlocks are not always detected in a distributed file system. When such deadlocks are possible All locks set on a file are automatically cleared by Note that there is a limit on the total number of locks a process may have at one time; this limit is imposed by the host operating system. Examples: Set exclusive lock on the whole of the file tied on tie number 100. All other users are prevented from locking any current or future segment of the file: ⎕NLOCK 100 2 Try to get a read lock on the first 1000 bytes of the file, with a timeout value of 2 seconds: ⎕NLOCK 100 1 1000 0 2000 Release all locks on the file: ⎕NLOCK 100 0 |
|
APLX Help : Help on APL language : System Functions & Variables : ⎕NLOCK Lock/Unlock native file
|
Copyright © 1996-2010 MicroAPL Ltd