I wrote software that runs a video service. That means I need to have code that handles video frames in realtime. For that purpose, I compute when the next frame is expected to "hit".
More or less, like most such software, I compute the time for the next frame which tells me whether I have time to wait or not.
When you write proper software next-frame is going to be in the future (i.e. you have enough CPU time to idle for a bit). That means you want to wait until that time to then send the next frame.
read more