100% CPU usage
100% CPU usage
Ok I understand Irrlicht updates like every second or something.
It's a rendering engine it makes sense.
But my menu only requires the GUI be updated every so often and even without a scene manager implimented it still uses 100% of the available cpu to update the GUI. (or at least I think thats whats happening)
So the question is, how can i reduce the cpu usage?
It's a rendering engine it makes sense.
But my menu only requires the GUI be updated every so often and even without a scene manager implimented it still uses 100% of the available cpu to update the GUI. (or at least I think thats whats happening)
So the question is, how can i reduce the cpu usage?
hi
just for completenes, the equivalent to the windows Sleep() on a *nix system is the usleep().
The sleep() defined in unistd.h has only seconds precision while the usleep() takes a msec argument. The highest precision is about 10 msec dependent on the granularity of the linux scheduler. When performing a usleep your process is rescheduled and the Linux scheduler (for the x86 architecture) usually takes at least about 10-30 milliseconds before it returns control to your process.
best regards
mba
just for completenes, the equivalent to the windows Sleep() on a *nix system is the usleep().
The sleep() defined in unistd.h has only seconds precision while the usleep() takes a msec argument. The highest precision is about 10 msec dependent on the granularity of the linux scheduler. When performing a usleep your process is rescheduled and the Linux scheduler (for the x86 architecture) usually takes at least about 10-30 milliseconds before it returns control to your process.
best regards
mba
thanks MBA... I'll push it one further with a half-arsed preprocessor macro then
luckymutt- yes, it's "Sleep(time_in_ms)". Andreas, see this thread for frame limiting info http://irrlicht.sourceforge.net/phpBB2/ ... php?t=8246
Code: Select all
#ifdef LINUX
#include <unistd.h>
#define Sleep(x) usleep(x)
#else
#include <windows.h>
#endif
The unistd.h defines standard routines used in a unix environment, and it contains unix specific code. You probably wouldn't use it on a windows machine.so let me get this straight usleep() works on both windows and linux?
so it's good to use this instead?
"Do not #include <unistd.h> as it contains UNIX-specific definitions. At the very least, check with your Windows environment before using functions or constants from <unistd.h>."
From:
http://www.opengl.org/resources/tutoria ... de389.html
But you would use it when doing something portable like the portable-macro bitplane was suggesting
#ifdef LINUX
#include <unistd.h>
#define Sleep(x) usleep(x)
#endif
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
so then would this be proper?
I'm sleeping Sleep(50); for the menu which is only GUI (no 3d not even a scene manager)
and I'm sleeping Sleep(10); for the Guice application to reduce the lag to a minimum where the menu has a touch of lag but really it doesn't seem to hurt anything and reduce cpu to almost nothing.
I have another question will it lag more on a slower system then my own?
#include <unistd.h>
#define Sleep(x) usleep(x)
#endif
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
so then would this be proper?
I'm sleeping Sleep(50); for the menu which is only GUI (no 3d not even a scene manager)
and I'm sleeping Sleep(10); for the Guice application to reduce the lag to a minimum where the menu has a touch of lag but really it doesn't seem to hurt anything and reduce cpu to almost nothing.
I have another question will it lag more on a slower system then my own?