Adds correct implementation of semaphore.
Week 4 assignment.