如果到超时时间段结束时还没有被唤醒,读线程需要唤醒自身并释放互斥锁。
If not awake otherwise, at the end of the timeout, the reader needs to wake itself up and release the mutex.
虽然旋转锁是cpu密集型的,显得效率低下,但是如果争夺的锁被持有的时间非常短,那么旋转锁要比暂挂线程然后再唤醒它更有效率。
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调度中。
When the thread that has the lock leaves the critical section, the suspended thread needs to be woken up. The thread will need to be re-scheduling and context switched back into the CPU.
应用推荐