running tasks or processes). File locking does not limit or block access to files within a single MTS session (between command language subsystems or user programs running as part of the same MTS session). File locking in MTS is mandatory rather than advisory. Files are locked implicitly on first use of a particular type of access or explicitly using the $LOCK command or the LOCK subroutine. Files are unlocked implicitly when the last use of a file within a task is closed or explicitly using the $UNLOCK command or the UNLK subroutine. The $LOCKSTATUS command or LSFILE and LSTASK subroutines can be used to obtain a file's or a task's current lock status. A file may be "open", "not open", or "waiting for open" and "not locked", "locked for read", "locked for modify", "locked for destroy", "waiting for read", "waiting for modify", or "waiting for destroy". A file's open status is independent of its lock status. Locking a file for modification also locks the file for reading and locking a file for destroying also locks the file for modification and reading. Any number of tasks can have a file locked for reading at any given time, but only one task can have a file locked for modification at any given time and then only if no task has the file locked for reading, or locked for destroying. Only one task can have a file locked for destroying at any given time, and then only if no task has the file open, locked for reading, or locked for modification. When an attempt to lock a file cannot be satisfied, the calling task will wait either indefinitely or for a specific period for another task to unlock the file, or until an attention interrupt is received. If the file cannot be locked, an error indicating this is returned. The file locking software detects deadlocks between tasks using Warshall's algorithm and returns an error indication without locking the file and without waiting. Locking a file is in effect locking the name of that file. For example, the following sequence of commands can be executed while leaving FILE1 locked even though a file with the name FILE1 does not always exist: $lock FILE1 RENAME $rename FILE1 as FILE2 $create FILE1 At a later date this capability to lock names allowed the "file" locking routines to be used to implement record level locking between tasks