1. If your fans are spinning up when you run a while(true); then you have a serious problem. That is not to say that you should run such a loop, but the idea that 100% CPU usage is going to overheat and melt your machine is ludicrous. That may have been true a long time ago, on hardware from the 1980s, but if your machine is melting down on a while(true); loop you've got a lot bigger issues than said loop.
I agree that just using 100% of the CPU is unlikely to cause damage, and mentioned so in my post.
But I do have recent experiences with overheating on graphics cards (much more common). One of my laptops is only a few years old and has been permanently damaged from overheating to the point where I can’t even turn it on anymore.
However, just dong a while ( true ) loop is not possibly going to cause such a case as you correctly point out.
2. Windows (and in fact pretty much every operating system you will find on PC class hardware) is a pre-emptive multitasking operating system. This means every single thread is allocated a slice of the CPU's time and when that slice of time is up it is preempted and another thread scheduled. All processes, in Windows, will get their own slice of time and a chance to do their work. If it were otherwise then your game would be unable to render, as all of the actual work happens during the driver/kernel's time slice. You can resource starve threads, but that's an issue for your own process and not for other processes that are running concurrently, and if you screw around with thread priorities you can increase your timeslice, but usually only to your own detriment (if you starve the kernel's threads... most of the work you schedule just doesn't get done).
I hope I didn’t come off as implying otherwise.
I just assumed the original poster is doing something
strange because I don’t think a normal empty game loop should otherwise be taking 60% of the CPU.
It turns out he was on Android, which explains that.
slicer4ever, in general a game should be trying to use all resources available.
But it should only be able to reach that point when it is actually a full game, not just an empty loop.
I still don’t see a problem between your replies.
You are on Windows, and while there are things to consider about power usage etc., it is not hugely important for you to consider them. Many games don’t. I have lost hardware because of it, but it is up to you to take those things into consideration on your own will.
I don’t think it is something that needs to be brought up every time this question is asked, so you don’t need to mind so much that it wasn’t mentioned in your post.
You got the correct reply for your needs.
It was just fortuitous that this poster also got the correct reply for his needs, which include battery conservation.
Edited by L. Spiro, 26 October 2012 - 05:32 AM.
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums