In a 4 processor system, which of the three processor (all the 3 processors are spinning to acquire the spin lock) will acquire the spinlock released by the fourth processor?
Asked
Active
Viewed 67 times
-1
-
Unless you have something like a ticket lock, there is no way of knowing. Besides, if there was a way of knowing for one particular platform, a different platform would not necessarily have the same memory ordering, so "a 4 processor system" is way too vague. – Damon Apr 02 '15 at 11:53
-
possible duplicate of [which processor will acquire the spinlock?](http://stackoverflow.com/questions/29413987/which-processor-will-acquire-the-spinlock) – Damon Apr 02 '15 at 13:58
-
I have removed the duplicate post so that this will continue as the solo post for the query. – Madara Apr 06 '15 at 08:46
1 Answers
2
In a simple spinlock it is nondeterministic. The first processor to test the spinlock after it has been released will get it. This can lead to starvation, when a process never gets the lock, becouse processes that request the lock after the waiting process keep getting it first. For this reason, and the waist of processor time to busy waiting most operating systems do not implment such a spinlock. Windows has a queued spin lock while Mac OS X and Solaris use an adaptive mutex.

Jackson Enix
- 71
- 6