A message for Linux.com registered users: We are in the process of making changes to the Linux forums. Starting Monday, 8/13/18 at 6:00 PM PT, you will be unable to access the forums. They will re-launch as soon as possible on Wednesday, 8/15/18 with new features and improved functionality. Thank you for your patience and stay tuned for the new improved forums.

April 10, 2013

In depth explanation of Spinlock, Semaphore, Mutex

Seeking in depth explanation for Spinlock, Semaphore, Mutex.
I tried Google but everywhere I am just getting basic working of these things. I need more explanation.

like,
1. what to use when and why.
2. what is system's status while using one of these
3. Concrete differences between these

Few things that I am Confused about

Mutex:-
1. Recursive locking allowed or not ?
Answer- As I think its operating system dependent.
2. holder can sleep or not ?
Answer- Can Sleep, even while holding lock.
3, is scope limited within the process ??? that is it can't be used between two process ?
Answer- Can be used between processes

4. It can't be acquired by interrupt handler or bottom half

5. to be used when u want long lock hold time ?????

6 its used for locking

Semaphore:-

1. Recursive locking allowed or not ?
Answer- not allowed ?
2. can sleep or not ?
Answer- Can Sleep.
3, is scope limited within the process ??? that is it can't be used between two process ?
Answer- Can be used between processes

4. its for synchronization or can be taken as signaling mechanism.

Thanks a lot!

Click Here!