MUTEX LOCKS

Mutex:

  • As the synchronization hardware solution is not easy to implement for everyone, a strict software approach called Mutex Locks was introduced. 
  • In this approach, in the entry section of code, a LOCK is acquired over the critical resources modified and used inside critical section, and in the exit section that LOCK is released.
  • As the resource is locked while a process executes its critical section hence no other process can access it.
  • Mutex is the short form for ‘Mutual Exclusion object’.
  • A mutex allows multiple threads for sharing the same resource.
  • The resource can be file.
  • A mutex with a unique name is created at the time of starting a program.
  •  A mutex must be locked from other threads, when any thread that needs the resource. When the data is no longer used / needed, the mutex is set to unlock.


What is spin lock?

  • In a loop a thread waits simply (‘spins’) checks repeatedly until the lock becomes available.
  • This type of lock is a spin lock. The lock is a kind of busy waiting, as the threads remains active by not performing a useful task.
  • The spin locks are to release explicitly, although some locks are released automatically when the thread blocks. 


No comments:

Post a Comment