I have a program waiting for messages from another process and it must have an infinite loop like for(; but I wouldn't like to have it using 100% CPU while it doesn't have messages to read.
How can I solve this problem? The messages are sent via shared memory.
I've been trying to use pthread_cond (since the reading part is in another thread). But the thread with an infinite loop is the one that can see when there is or not a new message.
Thanks in advance!