Separated the semaphore implementation from its running program.