Added a prototype for the semaphore loop
Changed the for loop in semLoop a bit.