View Full Version : CPU usage is about 100%
01-08-2006, 04:26 AM
When i run lesson 1 of nehe in one of the systems with the follwing properties, Cpu usage is about 100%:
ATI Radeon 7000 and cpu Intel 800 Full Cash
This program has nothing. It only creates a window and creates a GL context. CPU need to process empty loops and it's not so expensive. So what's the problem? In my system, the cpu usage is about 20%
01-08-2006, 04:59 AM
In the initialization (InitGL) , try to add (assuming that you are using GLEW)
Or add a
Sleep(1000/60); // Win32 functions
after the 'while(!done)' for the window message handling.
This will save CPU for other applications (also same power if running on laptop).
Also this will be multi-processord and multi-applications friendly.
01-10-2006, 11:41 AM
The CPU does not choose to process your empty loops at a particular rate, it will process your idle loops at FULL SPEED.
So an empty loop is pretty much guaranteed to burn 100% CPU unless you do something else in there.
Counterintuitively, drawing lots of fancy graphics with hardware acceleration inside that loop will ultimately stall the CPU waiting on the graphics card to finish and will free up some CPU time.
If you'e writing a game etc. don't worry about 100% CPU useage, better to hog the CPU than invite schedule latency pauses and stuttering etc. by trying to idle the CPU.
Most other apps need to be better behaved than games w.r.t. not hogging resources, but games pretty much can run as fast as possible IMHO.
It is ultimately your choice, you could try and idle the CPU instead of running what is effectively a busy wait loop.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.