Corrected implementation errors in the semaphore module