I'm using posix threads and have a workerRoutine that in some cases has to wait for I/O.
//WorkerRoutine
while(true){
if(NO CURRENT WORK){
//sleep for I/O
continue;
}
//Other cases....
}
My I/O function updates a statically-sized list. My problem is, when there's no current work for a worker, there's busy waiting. I'd like to have a sleep function in the worker function and a wake function in my readList (the I/O) function. What's the best way to do this in C?