the buggy semaphore implementation