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 root password has been changed, how can i enter into the system without root password?

6 Answers  


How to Trouble shoot performance issue in RHEL administration ? please give to one example

0 Answers  


someone already asked 'what is diff between unix & Linux' can I ask the same but more nuanced...I have 7 years app support of unix, have never seen Linux BUT need to bluff my way through in an interview i e say that I have use Linux. What are the most important things I need to know?

1 Answers  


Where is standard output usually directed?

2 Answers  


Friends, I don't have enough free space in root directory. but in home directory I have 40gb free. So I can not install anything in root directory (which occupies more space) Please suggest me If there is any possibility to increase the root directory size by minimising the home directory's.

3 Answers  






what is the difference betweenh the NFS and FTP?

4 Answers   IBM,


How To Hide the FTP Version?

3 Answers   Wipro,


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  


As a system admin i want to know some things what are the troubleshooting issues we are facing frequently and what are the tickets will be raised.

0 Answers   Ondot,


what is memory mapped / IO mapped ? Which calls used for this to access any hardware address in linux device driver ?

3 Answers   Broadcom,


What is the difference between an argument and an option/switch?

3 Answers   Wipro,


why accounting Software does not support on linux?

5 Answers  


Categories