Semaphores are Surprisingly Versatile

from blog Preshing on Programming, | ↗ original
In multithreaded programming, it’s important to make threads wait. They must wait for exclusive access to a resource. They must wait when there’s no work available. One way to make threads wait – and put them to sleep inside the kernel, so that they no longer take any CPU time – is with a semaphore. I used to think semaphores were strange and...