Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Lock

A lock is a mechanism used to control access to a shared resource so that only one process can use it at a time.

There are different kinds of locks:

  • File locks, when using flock() function
  • Database locks, via transactions or explicit locks in the database
  • Semaphore locks, based on sem extension.
<?php

    $sem = sem_get(123456);
    
    sem_acquire($sem);
    // critical section
    sem_release($sem);

?>

Documentation

See Also