|
|
|
|
|
by siddcoder
3375 days ago
|
|
I think spinlock is used when the critical section is relatively smaller where the threads are likely to perform small amount of work after acquiring locks. Thus locks are not expected to be held for longer duration. The other threads contending for the lock prefer to just spin and poll (and of course burn CPU) with the hope that lock will soon be relinquished by the owner thread. This way spinning threads avoid the overhead of context switching as well. Goes without saying, spinlocks are not useful on uniprocessor machines or single core machines. |
|