Linux

Table of Contents

Files

lock

  • Used to ensure that multiple instances of a program, which may be running concurrently on one system, don't access something at the same time.
  • Before a program accesses a resource:
    1. Checks for the presence of a lock file
    2. If it exists linux_1637525cf02f6fd6d9c4b23a99fde4e4c0783292.png error out or wait until it goes away
    3. If it doesn't exists linux_1637525cf02f6fd6d9c4b23a99fde4e4c0783292.png creates the file and thus locking the resource
  • Works because the filesystem under all UNIX-like OSes forces serialization, i.e. only one change to the filesystem actually happens at any given time.