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

Where is standard output usually directed?

2 Answers  


i want some basic level enterview questions can any one can help me in this

1 Answers   TCL,


What is the difference between ext3 and ext4?

0 Answers   IBM,


How can you see all mounted drives?

10 Answers  


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

1 Answers   Broadcom,






What text filter can you use to display a binary file in octal numbers?

1 Answers  


You want to create a compressed backup of the users' home directories. What utility should you use?

5 Answers  


1 which file contains information about os wether it's 32 bit or 64 bit os 2 difference between logical block and physical block?? 3 what is the size of logical block and physical block?? 4 daemon for nfs on client end as well as server end??? 5 how to confirm from client end about nfs server sharing?? 6 what contains information about file and directory creating time or modification time??

4 Answers   Oracle,


User unable to login in server then how can u troubleshooting it? Example: server at Bangalore. in that server two users try to login in server. 1st user able to login. but second user unable to login so how can troubleshoot it ?

5 Answers   Oracle,


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  


What is LILO?

11 Answers   Cisco,


How do i check which nfs version I am using ????????

9 Answers   CybAge, IBM,


Categories