what is the difference between semaphore, mutex &
spinlock?????



what is the difference between semaphore, mutex & spinlock?????..

Answer / guest

Kernel Locking Techniques
Semaphores in Linux are sleeping locks. Because they cause a
task to sleep on contention, instead of spin, they are used
in situations where the lock-held time may be long.
Conversely, since they have the overhead of putting a task
to sleep and subsequently waking it up, they should not be
used where the lock-held time is short. Since they sleep,
however, they can be used to synchronize user contexts
whereas spinlocks cannot. In other words, it is safe to
block while holding a semaphore.

A "mutex" (or "mutual exclusion lock") is a signal that two
or more asynchronous processes can use to reserve a shared
resource for exclusive use. The first process that obtains
ownership of the "mutex" also obtains ownership of the
shared resource. Other processes must wait for for the first
process to release it's ownership of the "mutex" before they
may attempt to obtain it.

The most common locking primitive in the kernel is the
spinlock. The spinlock is a very simple single-holder lock.
If a process attempts to acquire a spinlock and it is
unavailable, the process will keep trying (spinning) until
it can acquire the lock. This simplicity creates a small and
fast lock.

Is This Answer Correct ?    64 Yes 7 No

Post New Answer

More Linux AllOther Interview Questions

My Linux server in the two lan card one lan card is ok working but second lan card after restart daily lan card deactivate and then manual activate then properly working but after restart repeat this problem.(Fedora O.S.) Pls tell me solved this problem.

4 Answers  


am installed windows and later i installed ubuntu i want to unistall ubuntu can any one tel the procedure to uninstall ubuntu in my windows 7 please mail to me ---kiranpulsar2007@gmail.com and later i want to install ubuntu after uninstalling ubuntu tel the procedure for that also i dont know to patrition the hard disk drive please tel to them please reply

1 Answers  


I have accidently deleted my fstab... how do i recover/ regenerate the file?????? in rescue mode i cannot create a new file since the filesystem is readonly and could not mount in readwrite mode ?????????

6 Answers   IBM,


there are many IPC mechanisms available in Linux ? Which one is best to use and when ?

1 Answers   Broadcom,


What is the difference between RedHat linux and Fedora and Ubuntu?

3 Answers   CSC,






How to Create NIS Server And NIS Client? Explain With Example?

1 Answers   Cisco,


What is the complete name of the default configuration file for LILO?

1 Answers  


Tell me the 5 differences between Linux and Unix?

4 Answers  


what is the difference between semaphore, mutex & spinlock?????

1 Answers   Patni,


How to send automated email to a set of people at fixed time ?

3 Answers   Accenture, HP,


How can you see all mounted drives?

10 Answers  


What is the difference between semaphore and spinlock?

1 Answers  


Categories