... 优化屏障(Optimization barrier)、内存屏障(Memory barrier) 自旋锁(Spin Locks) 我们详细讨论一下spin_lock(slp)宏(slp代表要获取的spinlock_t): ...
基于26个网页-相关网页
Spin locks work well in cases where lock durations are very short.
当锁被占有的时间很短时,自旋锁的效果非常好。
Furthermore, we can define as many spin locks as we want, to guard as many Shared resources as we want.
另外,我们可以定义我们想要的旋转锁数量,来守护我们想要得共享资源。
While spin locks are CPU-intensive and appear inefficient, they can be more efficient than suspending the thread and subsequently waking it up if the lock in question is held for a very short time.
虽然旋转锁是cpu密集型的,显得效率低下,但是如果争夺的锁被持有的时间非常短,那么旋转锁要比暂挂线程然后再唤醒它更有效率。
应用推荐