Why Can CPU Utilization Exceed 100%? Exploring Time‑Slice Scheduling with C Examples
This article explains CPU time‑slice scheduling, defines CPU utilization as T2/T1, and demonstrates through C programs how different loops affect measured CPU usage, showing why multi‑core systems can report over‑100% utilization while single‑core systems cannot.
CPU Utilization and Time‑Slice Scheduling
In a multitasking operating system the scheduler assigns each runnable process a time slice T1 . The actual CPU time the process consumes during that slice is T2 . The ratio T2/T1 defines the process’s CPU utilization.
Low‑Utilization Example (sleep loop)
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
printf("%d: Cpu start...
", getpid());
while (1) {
sleep(1);
}
return 0;
}This program spends most of its time sleeping, so a monitoring tool shows a very low CPU usage.
Higher Utilization with Busy Loop
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i = 0;
printf("%d: Cpu start...
", getpid());
while (1) {
for (i = 0; i < 100000000; i++) {
/* busy work */
}
sleep(1);
}
return 0;
}The tight for‑loop consumes CPU cycles before each sleep, raising the measured utilization. The following screenshot shows the increase.
Maximum Utilization (no sleep)
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i = 0;
printf("%d: Cpu start...
", getpid());
while (1) {
for (i = 0; i < 100000000; i++) {
/* busy work */
}
/* sleep(1); */
}
return 0;
}Removing the sleep call makes the process consume almost all CPU cycles. On a multi‑core machine the reported utilization can exceed 100 % because the metric is summed across cores.
Key Observation
On a single‑core system the utilization of any process cannot exceed 100 % because only one core is available. On multi‑core systems the sum of utilizations across cores can be greater than 100 %.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
