Added (untested) semaphore implemenation