I have a problem using my raspberry pi 2 for applications that need low latency.
I wrote a c++ GPIO routine that reads a high resolution quadrature ttl encoder. It then updates a counter and adds it to a value being read by i2c channel from another thread. Then another GPIO pins create a quadrature ttl encoder output. To not lose any pulses I need at least a loop with 10 usec cycle time for encoder reading thread.
The program cycle time is less than 3 usec in 99.9% of the times. Only one out of 1000 time the cycle time becomes more than 2000 usec.
I think the os is running so many unnecessary tasks that I don't need. For instance I don't need graphics, desktop, networking, Bluetooth, USB or even keyboard or monitor. I tried to stop all the running services with no luck. Any help would be much appreciated.