Add sem_wait/sem_post to output()