A semaphore is a counter that controls access to a limited pool of resources. Think of it like a parking lot with N spaces - when all spaces are taken, new cars must wait.
acquire(): Decrement, block if 0release(): Increment, wake waitersSee how only N permits can be held at once. When all are taken, new requests wait in the queue until a permit is released!
Start demo to see events...
A semaphore is a counter that controls access to shared resources.
acquire(): Decrement counter (blocks if 0)release(): Increment counter (wake waiters)