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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

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.

1079


What are the differences between FTP , NFS , SAMBA servers explain separately.

702


What is Hard mount and soft Mount?

1361


what is the gate of ftp server in redhat linux?

1438


What is the difference between ext3 and ext4?

2010






i installed clustering packages.When i try to run it getting LUCI error...what is it..??

1946


This question is belong to linux support. "one of my customer told to me, my application is getting slow response". how to resolve the issue. what are the steps you will follow to resolve the issue.

1460


Why is it suggested to disable journalism in ext4 filesystem?

3057


why /etc/shadow file do not have any permission ?

1046


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

1627


1. User gaves df -h and the system get hanged. why ? 2. what is the hardlink and softlink mount ? 3. why is portmape should be started ? 4. what is nologin option 5. how to restrict users from accessing nfs ? 6. what is the difference between cpio and tar 7. what are the kernel parameters ? how to find out it ? 8. why we use sysctl.conf ? 9. if we gives init1 from multiuser runlevel, will it affect other users who already logged in to the system ? 10. what will be the available space to use after configuering raid5 with 5 disks each having 5gb spce ?

2288


How to catagories tickets in RHEL, which tickets are belong to PROBLEM, INCIDENT and CHANGE management? please given to me with examples

1330


I want to configure production interface and manage interface, how to configure both interfaces in Linux. please post the answers

1498


what is difference between  TFTP abd FTP?

1609