E
Eternally
Hey folks,
I'm writing a simple C++ application which runs continuously. I'm running
the program from the command line in Cygwin from XP, and it's
cross-compatible with Linux.
While running the program, I notice that the CPU usage is 100%, with my
application stealing 97% of it.
I'd like to bring that down to at most 10% of the CPU usage. What's the
trick to that?
I noticed that on certain applications like those used to decode video, you
can specify how much CPU to use (high priority, low priority...), how is
that accomplished? How can I bring my applications CPU usage down to 10%?
Note: I tried running sleep(1), and that brought it down below 10%, however
telling it to sleep for a full second is too much. A tenth of a second
would be fine, but sleep only takes ints. I then tried using clock() and
making it pause until a certain amount of time had passed like .005 of a
second, but the cpu sticks at 100% with that method (since it's running in a
while loop testing the amount of time passed....i.e. it's not really
sleeping).
Thanks in advance for the help!
I'm writing a simple C++ application which runs continuously. I'm running
the program from the command line in Cygwin from XP, and it's
cross-compatible with Linux.
While running the program, I notice that the CPU usage is 100%, with my
application stealing 97% of it.
I'd like to bring that down to at most 10% of the CPU usage. What's the
trick to that?
I noticed that on certain applications like those used to decode video, you
can specify how much CPU to use (high priority, low priority...), how is
that accomplished? How can I bring my applications CPU usage down to 10%?
Note: I tried running sleep(1), and that brought it down below 10%, however
telling it to sleep for a full second is too much. A tenth of a second
would be fine, but sleep only takes ints. I then tried using clock() and
making it pause until a certain amount of time had passed like .005 of a
second, but the cpu sticks at 100% with that method (since it's running in a
while loop testing the amount of time passed....i.e. it's not really
sleeping).
Thanks in advance for the help!