280 views
0 votes
0 votes
why spinlock requires context switch ?

1 Answer

1 votes
1 votes
Ur  question. is somewhat confusing.

In fact, Spinlocks have an advantage that there is no context switching as the thread would be put in loop checking the spinlock's state thus wont be context switched out. Thus, spinning is effective in case locks are held for short duration.

In traditional mutex, the thread would have been put to sleep when the lock was held by another thread and thus, context switched out.

Related questions

2 votes
2 votes
2 answers
1
Sunnidhya Roy asked Dec 30, 2022
676 views
Can Safe state in DeadLock Avoidance Mechanism always guarantee No DeadLock??
0 votes
0 votes
1 answer
2
0 votes
0 votes
3 answers
4
Vegeta asked Oct 22, 2018
897 views
All safe states are deadlock free. But we can go to deadlock with some combination of sequence? So if the question is, from the safe state can we enter deadlock? Ans shou...