<div dir="ltr">Hi,<div><br></div><div style>I am trying to write small program to get CPU usage for a particular process. My logic is to read user, nice, system, idle values from /proc/stat. Then read user and system time from /proc/&lt;pid&gt;/stat. Then wait for some time and again read same values. After that I am doing following calculations </div>

<div style>CPU% = (no_of_processor * (process_cpu_usage2-process_cpu_usage1) * 100 ) / (total_cpu_usage2-total_cpu_usage1)</div><div style><br></div><div style>When I compare my output with top, it looks like correct, but sometimes it is more than 100. Is my logic correct here ? Please correct me if I am worng.</div>

<div style><br></div><div style>Regards,</div><div style>Rahul </div></div>