This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit 4d04b0b
committed
Remove wrong advice about spin locks from
Using a pure spin lock for a critical section in a preemptable thread
is always wrong, however short the critical section may be. The thread
might be preempted, which will cause all other threads to hammer
busily at the core for the whole quant. Moreover, if threads have
different priorities, this might lead to a priority inversion problem
and a deadlock. More generally, a spinlock is not more efficient than
a well-written mutex, which typically does several spin iterations at
the start anyway.
The advise about UP vs SMP is also irrelevant in the context of
preemptive threads.spin_loop_hint docs1 parent 0ec3706 commit 4d04b0b
1 file changed
+2
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
| 137 | + | |
| 138 | + | |
147 | 139 | | |
148 | 140 | | |
149 | 141 | | |
| |||
0 commit comments