I have an application which uses boost asio and I would like to use
poll() to detect ready network events (packets) and process them as quickly as possible.
Additionally, I would like to use SCHED_FIFO for this process (which is single threaded) try to control the jitter (main problem I'm trying to solve..)
Now the limitation, the kernel is 2.6.32 (without real-time patch.) Which has the additional problem that there are some kernel processes which run on the core where my app is running which I cannot move out (i.e. the kernel doesn't appear to have true isolation - I know this comes in a later kernel - but I can't upgrade to that yet.)
So, now if I'm unfriendly, and I do the following:
This process will spin the core, and because SCHED_FIFO is set, it will never relinquish to the other kernel processes that need to run on this core, and all sort of unpredictable bad stuff happens. Now my question is, how I can do this poll loop and ensure that I relinquish so that the other threads get to run for a little bit at least?
I see two options,
- Some sort of sleep
- if no events were handled by
poll(), I could call
run_one()which blocks for one event only, but the problem here is that this event could be the packet I want, and now I have jitter again...
Have I missed any other approaches?