Semaphores homework - working example