Hi !

I have one problem because one my application written in c++
occasionally used 100% of CPU.

Does anybody have any idea how to write a program, which report what is cause of that behavior or how to figure out why this happen?


Thanks.

Primoz.
Posted on 2002-06-22 04:21:13 by primozz
"Occasionally use 100% cpu time" is a very common phenomenan. Why do you think a runnin process should not take 100% cpu time when it IS necessary?:)
Posted on 2002-06-22 04:27:42 by C.Z.
Hi !

OK, First Issue:
When process started to use 100% CPU hangs up, and never
decrease usage...

Second:
- it's not anything different happening when process increase to 100 % CPU usage...

I would like to capture this event when CPU usage increase to figoure out where is the problem.

Do you have any other idea ?

Thank's for any help.

Primoz
Posted on 2002-06-22 15:42:24 by primozz
check any loops if you have them, it seems to me that a break condition is never met
Posted on 2002-06-22 16:10:23 by Hiroshimator
or a function that "ran into" another /wo a ret. for example something like:




push 5
call AA
...

AA proc
pop eax
sub eax,10

AA endp

BB proc
pop eax
...
ret
BB endp


or something like that... happened to me a few times and my program also gets stuck doing a loop for a count that is very high (because it assumed a variable was set just before it was called)
Posted on 2002-06-22 18:46:33 by jademtech
I have one problem because one my application written in c++ ...

I would like to capture this event when CPU usage increase to figoure out where is the problem.

Do you have any other idea ?
debug it using a debugger? or place something like this on a particular loop?


for( ;; )
{
//console
cout<<"REAL MEN CODE IN HEX :-) - This sh*tty loop is causing the problem."<<endl;
//win32
Messagebox(NULL, "REAL MEN CODE IN HEX :-) - This sh*tty loop is causing the problem.", "Non-Terminating Loop", MB_OK);
}
If you see an undending repetition of this text/messagebox then that's the bugger!!! :)
Posted on 2002-06-22 18:57:05 by stryker
Hi !

OK, possible causes (from your replays)
- infinitve loop
- variable was set just before it was called

It is possible to use somthing like:
- when access violation happens -> Dr. Watson (example)
- when process hangs-up || strat to using 100% - > CPU hook


Does anyone written any "CPU hook" or have any idea how to write it ?

It's seems to me that this is very interesting ???

Regards,
Primoz.
Posted on 2002-06-23 07:36:20 by primozz
Windows NT OSes have the system monitor to watch for such things. It should be incorporatable into your program. Look on MSDN for some articles about it. It has been written about in MSJ/MSDN magazine before.
Posted on 2002-06-23 07:44:30 by Hiroshimator