I'm working on a program that sends of a sound to a device in packets, when it's time to send of the packets I need to wait for a confirmation that the packet got to the destination and all is well before sending the next one.

Up until the sending part of my program everything is done in one thread. What I want to do is to do the sending in a new thread then use some mechanism in pthreads library to put it to sleep until I get the notification back from the receiving end.

I've been thinking about using a mutex but since I'm not really trying to protect a shared resource here I don't think this might be the best option. All I wan't is to wait for a condition to be true. I'm most familiar with the mutex though, and it might work to the same effect, although I'm a bit uncertain what would happen if I for some reason got a confirmation from the receiving end before I managed to pass the lock to the main thread?

Is the pthreads conditional variables a better choice in this case? What I would like to know basically, is if there are some tried and often used pattern I can apply here.

Thanks