Quote:Original post by Spoonbender
Try quitting your game and call up the task manager. The Idle process usually uses 99% of the CPU. That means the CPU is doing nothing 99% of the time. So why shouldn't your game take the CPU time it's offered? If you make your game call Sleep, and give away the CPU, then that will just go to the Idle process, which does nothing with it. How is that an improvement?
(And yes, I know I simplified all the above quite a bit)
Nice explanation overall (rating++), although I would point out that your simplification makes it sound like there is no point to calling Sleep() in a game. It is not necessary, certainly, for all the reasons you listed, but if one has the time, it is nice to add a bit of code which throws in some real short Sleep() calls whenever the game is running faster than say, 60 FPS. This increases the responsiveness of the rest of the system a bit, since the OS seems to have an easier time freeing CPU cycles from the idle process when other apps need it than from a game, and it also makes it so that your game won't necessarily cook the user's processor; the idle process is a bit different than a busy loop because it somehow actually lets the processor idle, and thus use less power and generate less heat. And it doesn't decrease responsiveness if you do like I said and only use Sleep() when the game is already running so fast the user can't tell the difference. Definitely not necessary, but I like to do it if I have time, since it always pisses me off when game designers assume that no one will want to switch away from their game but still leave it running.