soft implementation of ta_sem_wait()