Problem with semaphore_wait & its correct usage.