What is the standard way to resolve these issues?
There are real-time operating systems (RTOS) that guarantee such delays. This is a completely different class of operating systems than Windows or Linux.
But still, you can do something that can be done with delays even on general-purpose operating systems.
1. Avoid system calls
As soon as you ask your OS to read or write something to disk, there are no guarantees regarding delays. Therefore, avoid any system functions on your critical path:
- even functions like gettimeofday () can cause unpredictable delays, so you should really avoid system calls in time-critical code;
- - .
, , strace Linux Dr Memory Windows, .
2.
Windows . , , CPU. , RTOS, , :
- , ββ;
SetThreadAffinityMask() (Windows) sched_setaffinity() (Linux) - , CPU;- , ; CPU 0, CPU 1 +;
- , .
, perf (Linux) Intel VTune (Windows), .
3.
:
- swap, , ;
- CPU turbo boost - , (TDP);
- - , , .
, .