-1

When we use _task_manager_ in windows or top in Linux, we could see that the cpu usage is usually not very high. Moreover, developers are also doing their best to let this target come down. Actually, if the cpu usage is very high, we consider that something goes wrong there.

But I learned from most of OS textbooks that we want to make the best use of CPU, not wasting the CPU resources. But actually most of the time, our CPUs are in idle.

This confuses me a lot. why do we have this contradiction? Could someone shed light on this please?

3
  • 2
    If you have a 500 horsepower car, how often do you think you will actually put the "pedal to the metal" and use all 500 HP? The same concept goes with your computer. There is no contradiction. When your CPU is at 100% load, that means that during every task scheduler interrupt, something will always be scheduled (i.e. there is no idle time where the CPU just executes a NOP). Jul 14, 2013 at 0:53
  • 1
    @Breakthrough, it is actually a very good question. And there is an analogy in the car world to how both are solved... Jul 14, 2013 at 0:55
  • From @Breakthrough 's answer, I think I should the know how cpu usage is computed, which directs me to superuser.com/questions/432440/…. system_dile is also one process, with lowest priority. Then I can understand that the cpu is running all the time with reasonable response time if the cpu usage is not very high.
    – Alex
    Jul 14, 2013 at 3:49

3 Answers 3

3

It's not actually a contradiction. Think about your own day. You have tremendous capacity to achieve work and, at times, do not have enough time to get everything done because you have too many simultaneous tasks or deadlines... Then on other days you sit around without accomplishing much at all.

In a very similar way our computers actually tend to spend a great deal of time waiting around for us. Even so, as programmers, we try to keep our code optimized not only so that it can execute quickly and produce results as fast as possible but also to optimize system resources. This way, if it's a "busy day," we're trying to avoid contributing to "contention" (simultaneous demands for the same hardware resources) within the system.

For an example of technologies made possible by this interesting situation take a look at modern virtualization products. The reason that we can run 10 or 20 virtual machines simultaneously on a dual or quad core processor with only 4 or 8 gigs of RAM is that all of those systems are not attempting to use lots of memory and processor time simultaneously. (Of course, you have to either get beefy hardware or judiciously select which systems will be virtualized in the same host or you will create contention issues!)

3
  • Do you mean that the workload on the physical CPU with virtualization is higher than the one without virtualization? Or can I regard it as one of reasons that virtualization comes into play, that is, maximize the physical hardware utilization?
    – Alex
    Jul 14, 2013 at 3:36
  • Or to ask another question, is the CPU usage for data centers or servers usually very high? is there such a range for physical CPU usage?
    – Alex
    Jul 14, 2013 at 3:55
  • @Alex, yes that is largely correct, we virtualize to maximally utilize hardware capacity. the other big bonuses are: reduction in hardware and power costs, greater flexibility in clustering (VMs can be moved from one host server to another as needed), the ability to allocate servers dynamically (if your site has too many users, bring 10 more servers online automatically to deal with the load). Jul 14, 2013 at 6:22
2

To expand on Breakthrough's remark "If you have a 500 horsepower car, how often do you think you will actually put the "pedal to the metal" and use all 500 HP?"

Oddly enough, this parallels car engines and CPU's.

With a car, if you have a 500HP engine, you want to have that power available sometimes, but when it is not needed you can have cylinder de-activation just like in Dodge trucks and the C7 Corvette.

CPUs do the same thing, AMD calls it Cool and Quiet and Intel calls theirs Speedstep. Both are meant to lower clockspeeds and energy consumption at idle, and increase it when required.

2

Here you have one of the fundamental differences between abstract computer science/electrical engineering, and modern practical end user computing. There isn't a contradiction at play per se, but a difference in perspective and goals.

to put it bluntly, they are thinking of servers and supercomputers, and hundred-user mainframes, and the large, constant workloads that come with them, whereas the end user is thinking of loading web a web page once and reading it for 10 minutes, or opening a document and editing it at human typing speed, or maybe at most ripping a DVD, or running a virus scan, or playing a game (cpu intensive tasks that take more than a couple seconds, and whose primary bottleneck is IO speed).

both of these mindsets optimize the most important characteristic of their environment, time versus cost and power consumption.

if you are running a High performance cluster that runs mathematical calculations on batches of radio telemetry or runs advanced continuous simulations, or has capacity for hundreds or thousands of users, you think about things differently. a few milliseconds of inefficiency in each calculation a sim performs could manifest in years of difference in the processing of a large dataset.

the client user however is more focused on just being able to multitask a goodly number of small short lived loads, and is more concerned about affordability, low power usage, and quietness than they are about millisecond differences in computation time.

Not the answer you're looking for? Browse other questions tagged .