Mutex and Semaphores

less than 1 minute read

  • This is a tool for solving Critical Section Problem.
  • It provides Mutual exclusion.
  • This is a locking Mechanism, used to synchronize access to a resource.
  • Only 1 task acquires the mutex and that task only can release the mutex (lock).
  • At any point of time, only one thread can work on entire buffer.
  • It protects critical regions and hence prevents race around condition, that is , a process must acquire a lock before entering a critical section.
  • This lock is released when a process when a process exits critical section.
  • There are 2 function to this -
    • Acquire - To acquire the lock
    • Release - To release the lock after critical section code is finished execution.

Acquire Definition -

Release Definition -

Updated: