Properly implement DEFINE_SEMAPHORE