views:

53

answers:

1

I'm trying to recognize a run away threads in my own application and close them for good before they render machine inaccessible.

However, I can only get CPU time for the thread, that is limitation of API I'm using. Is there any way to evaluate CPU utilization from that data?

I was thinking about comparing it to real time and if it is close - than that thread is loading CPU too much. What do you think about that heuristic, will it work?

+2  A: 

CPU time divided by real time will give you CPU utilization.

Ignacio Vazquez-Abrams
It'll give me percentage of how much time thread spent working instead of waiting. It won't give me what percentage of the current CPU load my thread is making, which is what important to me. Although, I think checking cpu time / real time for 5 minutes back would be sufficient enough for my needs.
vava