fixed small issue in semaphore and returning null or negative initialvalue for semaphore_init