1,336 views
0 votes
0 votes
Is there any difference between busy waiting and spinlock

What is the meaning of this statement

"advantage of a spinlock is that no context switch is required when a process must wait on lock, and a context switch may takes considerable time  Thus when locks are expected to be held for short time spinlock are useful"

I can't understand this statement

Please tell with example..

1 Answer

0 votes
0 votes

Spin Lock is another term for busy waiting. Assume if context switching between processes takes x ms, and maximum amount of time a process needs to wait for a resource to be available be y ms, then its clearly noticeable that if y < x, then you're better off waiting than switching to some other process. So basically, what spin lock does is that it makes the process "spin" in a loop while waiting for the resource to be available.

Related questions

0 votes
0 votes
1 answer
1
N3314nch41 asked Sep 10, 2023
360 views
How to approach synchronization (specifically semaphore) question, there size are really intimidating and i’m unable to decode the code written? What to do??