10
3
I am watching my CPU percent utilization by a process. How does a process use only 50% CPU? Doesn't a process use 100% then 0%, then 100%? Its not like every other instruction is a different program.
10
3
I am watching my CPU percent utilization by a process. How does a process use only 50% CPU? Doesn't a process use 100% then 0%, then 100%? Its not like every other instruction is a different program.
16
It only polls totals about once per second. You're looking at how much of the last second it used.
If you see a cpu sitting at 50% for a little while, what's likely going on is that it's using 100% of one cpu in a dual cpu system.
4"one core of a dual core system" -- ... or even a single CPU with 'hyperthreading'. – None – 2009-09-14T19:57:38.340
@ChrisW: fixed. – Joel Coehoorn – 2009-09-14T20:00:35.107
CPU usage percentages are often reported out of 100% for each CPU individually, so the total amount of CPU power to be used in a dual core system is 200%, in a quad core 400%, etc. – David Z – 2009-09-15T03:57:27.070
Not in windows task manager they're not. – Joel Coehoorn – 2009-09-16T01:21:18.873
11
Technically you are correct. At any given time, the CPU is either being used, or not used. But displaying that in a graph wouldn't be very helpful, so the graph is averaging CPU utilization over some period of time, probably each second.
3
The OS schedules the process for a certain time period. So if the process is scheduled for (say) 1ms out of 10ms, then it will be using 10% CPU.
It's a little counterintuitive, since (in a single-threaded, single-CPU system), the process is either running, or not running. i.e. it's using 100% or 0%. The percentage that you see is measured over a time window and is a measure of the OS allocating time slots to your process to run.
Note that your process will not contribute to this if you're accessing I/O. So if you're doing a huge calculation, you'll register 100% (assuming nothing else runs). If you then wait for a network packet/disk access etc. your CPU figure will go down, despite the fact that your process is still running.
2
At a very low level, you're basically right. At any given instant, the processor is either executing an instruction for a given process or it isn't.
But your OS is sitting in between your processes and the processor, making them share time. The percentage you see is the percentage of recent processing time the OS has granted that process.
1
It based on the average time. Despite all threads can have the same parcel of CPU time (based on priority), the threads can just say "thanks but I'm idle", and pass it's turn to the next thread. Thats why programs are not always using the same % time, and most programs are consuming 0% CPU, and programs which really need CPU can take near 100% of time for itself.
Why is it capping at 50%? You probably have two CPU cores, and its using only one.
Or, as suggested, it is using hyperthreading, but I don't know how this one behaves exactly.
0
You program might be doing a lot of I/O (disk or network reads/writes). That would keep the program busy but need little to no CPU time.
0
System utilization is sampled and averaged, which is the only sensible thing to do.
E.g. a record of how much time a process/thread spent running during 1 second is kept. If it spent 1 second on the CPU, that's 100% CPU (or 50% if you have 2 CPUs and so on), if it spent 100ms that's 10% CPU utilization.
1Got a dual processor by any chance? – None – 2009-09-14T19:54:57.863
Definitely a question for SuperUser. – Noldorin – 2009-09-14T19:56:39.030