What is the difference between semaphore and spinlock?



What is the difference between semaphore and spinlock?..

Answer / sandeep

Spinlock is a busy wait. Semaphore is a sleep wait.
Spinlocks are used to get exclusive access to critical
section whereas semaphores are used for exclusive access and
also to synchronize processes and threads.
Spin locks are used when the critical sections it is
protecting is small and are held for a short time.
Semaphores can be held for longer time. Semaphores use spin
locks to access its control structures.
Spinlocks are kernel locking mechanism where as semaphores
are used in both kernel and user space.
Semaphores should not be used in interrupt handlers since
the code sleeps if the semaphore is not acquired.

Is This Answer Correct ?    7 Yes 0 No

Post New Answer

More Linux AllOther Interview Questions

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  


what is the difference between fork and thread ? and parent and child process in fork system call?

3 Answers   Satyam,


how do i check which package has installed some command suppose ls , mkdir or whatever ???

8 Answers  


will u plz send me the complete steps of installation of red hat linux on intel's core 2 duo processor?

1 Answers  


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,






how can i make an user to nologin without locking the account for the user

7 Answers   CSS, CSS Corp,


1.how to know cpu information on linux system? 2.how to hardware information on linux system? 3.if we add the new user what are the files will be changed? 4.how to remove the cache in squid server ? 5.how to know ur useing 32bit r 64 bit os ? 6.at booting process at init level which file it is reads? 7.if ur system performance is show what can u do ? 8.if ur file system corrupted what can u do ? fsck also not working? 9.how did u do health check in linux? 10.how did u check system performance in linux? 11.how did u create NIS server? give me the steps ? 12.how did u add a packages in linux ? 13.how did u know depended packages for any package useing rpm how u know? 14.how did you monitor cronjobs in linux ? 15.what is the use of logroted? and how did u do ? 16.port no is already in use so what canu do for that in http? 17.how to samba configurated are not ? there are any command for that ? 18.how to create a NTP Client using commands ? not as graphical... 19.how to know how many members are using any service? like ftp are any other services? 20.what is the differences between cmp,diff,comm commands?

3 Answers  


Hi all Could u plz tell me how I can get UNIX/Linux Certification

2 Answers   Accenture,


what is difference between inetd and xinetd

2 Answers  


What is the difference between ext3 and ext4?

0 Answers   IBM,


There are 4 network Interfaces, how can we find which one is Primary.

2 Answers  


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

1 Answers  


Categories