User avatar
makem
Posts: 231
Joined: Tue Jun 18, 2013 9:22 pm

Is CPU usage above 100% really possible?

Tue Jun 12, 2018 3:49 pm

Wow, %age CPU:

Image

Code: Select all

pi@RPIplus:~$ /opt/vc/bin/vcgencmd measure_temp
temp=40.8'C
pi@RPIplus:~$

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 19518
Joined: Sat Jul 30, 2011 7:41 pm

Re: Is this really possible?

Tue Jun 12, 2018 4:09 pm

Yes (sadly). The Pi has four cores, each of which can run up to 100%. Four cores running at 100% makes top display 400%...
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

User avatar
makem
Posts: 231
Joined: Tue Jun 18, 2013 9:22 pm

Re: Is this really possible?

Tue Jun 12, 2018 4:39 pm

jamesh wrote:
Tue Jun 12, 2018 4:09 pm
Yes (sadly). The Pi has four cores, each of which can run up to 100%. Four cores running at 100% makes top display 400%...
Why sadly?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 19518
Joined: Sat Jul 30, 2011 7:41 pm

Re: Is this really possible?

Wed Jun 13, 2018 11:35 am

makem wrote:
Tue Jun 12, 2018 4:39 pm
jamesh wrote:
Tue Jun 12, 2018 4:09 pm
Yes (sadly). The Pi has four cores, each of which can run up to 100%. Four cores running at 100% makes top display 400%...
Why sadly?
Because you had the ask the question - it's just a confusing way of looking at it.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

fanoush
Posts: 324
Joined: Mon Feb 27, 2012 2:37 pm

Re: Is CPU usage above 100% really possible?

Wed Jun 13, 2018 12:19 pm

Well, the other way is also a bit confusing. I often see in windows task manager something eating 12% CPU and it is is not so clear at first sight this is single threaded cpu bound process using 1 of 8 cores at 100%. With cpu usage so low one would guess the process is sleeping or doing some i/o but if fact the CPU is the bottleneck.

User avatar
makem
Posts: 231
Joined: Tue Jun 18, 2013 9:22 pm

Re: Is this really possible?

Wed Jun 13, 2018 2:36 pm

jamesh wrote:
Wed Jun 13, 2018 11:35 am
makem wrote:
Tue Jun 12, 2018 4:39 pm
jamesh wrote:
Tue Jun 12, 2018 4:09 pm
Yes (sadly). The Pi has four cores, each of which can run up to 100%. Four cores running at 100% makes top display 400%...
Why sadly?
Because you had the ask the question - it's just a confusing way of looking at it.
Yes, agreed. The 'correct' %age usage is in the top left hand corner so I cannot see why this is repeated on a total core usage basis unless it stated core1 @ %, core2 @ % etc. because a total % of 1 to 4 does not seem useful, not to me anyway.

Actually it raises a question, is the load spread evenly over all cores or does it spread across them as each core reaches a predetermined %age?

jahboater
Posts: 2622
Joined: Wed Feb 04, 2015 6:38 pm

Re: Is CPU usage above 100% really possible?

Wed Jun 13, 2018 3:18 pm

Actually it raises a question, is the load spread evenly over all cores or does it spread across them as each core reaches a predetermined %age?
Probably the former.

CPU usage is always 100% :)
That is, the CPU is either executing instructions or idle, nothing in between.
50% utilization is in fact 100% of the CPU for 50% of the time.

Apart from that, multiple processes sharing a CPU with time division multiplexing are constantly having to context switch. If they were spread across all the CPU's there would be less overhead.

There used to be a task that distributed interrupts evenly across the CPU's.

User avatar
makem
Posts: 231
Joined: Tue Jun 18, 2013 9:22 pm

Re: Is CPU usage above 100% really possible?

Wed Jun 13, 2018 6:05 pm

jahboater wrote:
Wed Jun 13, 2018 3:18 pm
Actually it raises a question, is the load spread evenly over all cores or does it spread across them as each core reaches a predetermined %age?
CPU usage is always 100% :)
That is, the CPU is either executing instructions or idle, nothing in between.
50% utilization is in fact 100% of the CPU for 50% of the time.
So, for each 'job' the processor(1, 2, 3 or 4), works flat out for 50% of the time the job takes to complete? That's strange, so I wait for 50% of the time while nothing is happening for the 'job' to complete?

I don't think so. I believe the 'job' starts and the %age of the processor's usage increases or decreases as necessary to complete the 'job' in the shortest possible time.

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 4474
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: Is CPU usage above 100% really possible?

Wed Jun 13, 2018 6:29 pm

makem wrote:
Wed Jun 13, 2018 6:05 pm
...
I don't think so. I believe the 'job' starts and the %age of the processor's usage increases or decreases as necessary to complete the 'job' in the shortest possible time.
I suspect (historically**, maybe) that job priority (niceness?) may also play a part.
Trev.
** Assuming "niceness" works along similar lines to the JCL methods of "ye olde mainframes" when you had to pay for computer (processing) time. :-)
Still running Raspbian Jessie on some older Pi's (an A, B1, B2, B+, P2B, 3xP0, P0W) but Stretch on my P3B+, P3B, B+, A+ and a B2. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

jahboater
Posts: 2622
Joined: Wed Feb 04, 2015 6:38 pm

Re: Is CPU usage above 100% really possible?

Wed Jun 13, 2018 6:37 pm

makem wrote:
Wed Jun 13, 2018 6:05 pm
I don't think so. I believe the 'job' starts and the %age of the processor's usage increases or decreases as necessary to complete the 'job' in the shortest possible time.
I meant the CPU can either be executing an instruction, or it is idle (or sleeping on x86). It cant "half" be executing an instruction, it either is or it isn't :)
Tools like top record the percentage of time within the measurement interval that the CPU was actually executing instructions.

jahboater
Posts: 2622
Joined: Wed Feb 04, 2015 6:38 pm

Re: Is CPU usage above 100% really possible?

Wed Jun 13, 2018 6:45 pm

FTrevorGowen wrote:
Wed Jun 13, 2018 6:29 pm
makem wrote:
Wed Jun 13, 2018 6:05 pm
...
I don't think so. I believe the 'job' starts and the %age of the processor's usage increases or decreases as necessary to complete the 'job' in the shortest possible time.
I suspect (historically**, maybe) that job priority (niceness?) may also play a part.
Trev.
** Assuming "niceness" works along similar lines to the JCL methods of "ye olde mainframes" when you had to pay for computer (processing) time. :-)
Yes thats right. Although its upside down! Reducing nice increases effective priority,
When the clock interrupt occurs it probably just takes the runnable process with the highest priority.

UNIX had the rather clever idea, compared to other OS's of the day, that the priority was inversely proportional to the CPU time used in the last interval. Thus someone typing at a keyboard using little CPU would get good interactive response, but a CPU intensive batch job would get lower priority and run in the background (and round robin with the other big jobs). And so on. Very clever in that it solved 99% of the problems with one trivial equation. Niceness just adds an offset to that calculation.

User avatar
DougieLawson
Posts: 32657
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Is CPU usage above 100% really possible?

Thu Jun 14, 2018 8:55 am

With top press the [1] key and you get the CPU broken down by core.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

mfa298
Posts: 1152
Joined: Tue Apr 22, 2014 11:18 am

Re: Is this really possible?

Thu Jun 14, 2018 10:47 am

makem wrote:
Wed Jun 13, 2018 2:36 pm
Actually it raises a question, is the load spread evenly over all cores or does it spread across them as each core reaches a predetermined %age?
The complete answer there probably gets more complex.

A single process/thread can only run on a single core at a time*. Luckily most applications these days run in multiple processes/threads and you have more than one thing running on a system at a time. This means the load usually gets spread over the multiple cores sensibly (If you had a bunch of background processes and one single threaded cpu bound application then you might find one core is running at 100% when the others are only at 5%).


* in the early days of multicore machines some things (usually games or other specialised applications) were heavily optimised to run really well in a single thread. So for some tasks a single core 3GHz machine was preferable to a dual core 2GHz machine.

Return to “Beginners”

Who is online

Users browsing this forum: thagrol and 45 guests