I'm working in a part of a bigger project, that has to read from a lot of FIFOs and redirect them properly, depending on the commands. To achieve this, the FIFOs are read in order, in an infinite loop.
The problem is that it consumes too much resources. I can understand that this process is always doing operations and waking up the processor, but I'd like to avoid so much overload.
- An option is using signals, but it makes the processing a lot more chaotic, and it's difficult to avoid cutting execution while processing one of the commands.
- Another option is using blocking read, but then I would need a process for each FIFO, because I don't know who and when will send a command.
- Another option is sleeping, but I don't think is the best option, and only sleeping a few milliseconds is not a lot of difference (I haven't tried yet).
Do you have any other ideas to avoid so much overloading?