I'm looking for a way to do timing events in C/C++ under Linux.
E.g. execute a piece of code every 100 milliseconds. (No more, no less, soft real-time)
The only options I've seen till now are:
- Looping infinitely, and check every time if it is time to execute.
- Sleeping the thread until it is time to run.
Infinitely checking if it is time to run, has the disadvantage that it is (too) CPU intensive.
Sleeping until it is time, has the disadvantage that it is not precise. The sleep-time is just a guideline, it could sleep way more.
Now I was wondering if any of you know how to do real-time timing events in C/C++ under Linux.