Finished task2b using semaphores