Implemented semaphores and overflow/underflow conditions; test thoroughly.