Thursday, March 27, 2014

Mutex, Semaphore and Spinlock

Some of the differences between Mutex and Semaphore in Windows CE

Mutex
  • Is used for Mutual Exclusion
  • It has either TRUE or FALSE state
  • It is possible that if a thread takes the Mutex, then the same thread can unblock on the same Mutex
  • Mutex implements Priority Inheritance

Semaphore
  • It can be either binary or counting semaphore
  • Each time the thread waits on semaphore the count is decremented, once the count reaches zero it can't unblock on the same semaphore even though it is owned by the same thread
  • Semaphore doesn't implements the Priority Inheritance

Spinlock
  • From Windows Compact 7 documentation it shows that spin locks are supported as they have added SMP support