Implementing semaphores.