semaphore

Changed Semaphores with counter and some macros