initialize semaphores with values for count and sem_queue
small bug fixes and variable renaming