File Locking

File locking is a mechanism that restricts access to a computer file by allowing only one user or process access at any specific time. Systems implement locking to prevent the classic interceding update scenario (see race condition).

It may also refer to additional security applied by the user of computer either by using Windows security, NTFS permissions or by installing a third party file locking software.

The following example illustrates the interceding update problem:

  1. Process A reads a customer record from a file containing account information, including the customer's account balance and phone number.
  2. Process B now reads the same record from the same file so it has its own copy.
  3. Process A changes the account balance in its copy of the customer record and writes the record back to the file.
  4. Process B, which still has the original stale value for the account balance in its copy of the customer record, updates the account balance and writes the customer record back to the file.
  5. Process B has now written its stale account-balance value to the file, causing the changes made by process A to be lost.

File locking prevents this problem by enforcing the serialization of update processes to any given file. Most operating systems support the concept of record locking, which means that individual records within any given file may be locked, thereby increasing the number of concurrent update processes.

Database maintenance uses file locking, whereby it can serialize access to the entire physical file underlying a database. Although this does prevent any other process from accessing the file, it can be more efficient than individually locking a large number of regions in the file by removing the overhead of acquiring and releasing each lock.

Poor use of file locks, like any computer lock, can result in poor performance or in deadlocks.

Read more about File Locking:  In Mainframes, In Microsoft Windows, In Unix-like Systems, On Amiga OS, Lock Files, Unlocker Software

Famous quotes containing the word file:

    While waiting to get married, several forms of employment were acceptable. Teaching kindergarten was for those girls who stayed in school four years. The rest were secretaries, typists, file clerks, or receptionists in insurance firms or banks, preferably those owned or run by the family, but respectable enough if the boss was an upstanding Christian member of the community.
    Barbara Howar (b. 1934)