Spin Lock vs Mutex

Some of the important difference between Spin Lock and Mutex are:

SpinlockMutex
Spinlock is a busy waiting lock, that is process or thread is not put to sleep that is Process Descriptor(PD) or Thread Descriptor(TD) is not added to wait queue.Mutex is a sleeping lock that is process or thread is put to sleep that is Process Descriptor(PD) or Thread Descriptor(TD) is added to wait queue.
There is no context switching involvedContext switching is involved.
This is useful for small critical section, else wastes CPU cycle.This is useful for long critical sections otherwise a frequent context switching adds overhead.
Preemption is disabledPrremption is enabled.



Categories: Operating system (OS)

3 replies

Trackbacks

  1. Mutual Exclusion (Mutex) - Tech Access
  2. spinlock - Tech Access
  3. Index of Operating System - Tech Access

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: