Make sleep interrupts more robust by using Semaphore.