semaphore

52 阅读1分钟

Goal

optimize for uncontended (common) case

Implementation idea

Uncontended case: use atomic operations

Contended case: use spin locks and wait queues

Linux semaphore structure

image.png