spin_lock为什么要关闭抢占?

The reason that preemption is disabled on a uniprocessor system is:
If not:
P1 holds the lock and after a time is scheduled out.
Now P2 starts executing and let’s say requests the same spinlock. Since P1 has not released the spinlock, P2 must spin and do nothing. So the execution time of P2 is wasted. It makes more sense to let P1 release the lock and then allow it to be preempted.
Also since there is no other processor, simply by disallowing preemption we know that there will never be another process that runs in parallel on another processor and accesses the same critical section.

spin_lock为什么要关闭抢占?spin_lock为什么要关闭抢占? 杨幂的咪 发布了26 篇原创文章 · 获赞 10 · 访问量 1万+ 私信 关注
上一篇:[20210218]shared latch spin count 5.txt


下一篇:wordpress 傻瓜式美化:简单的一行代码立即让您的菜单小图标旋转起来