What is CPU time?
The total time the CPU spent executing a program's instructions, excluding waits; with parallel execution it can exceed wall-clock time.
Japanese name: CPU時間
The total time the CPU spent executing a program's instructions, excluding waits; with parallel execution it can exceed wall-clock time.
Japanese name: CPU時間
Wall-clock time, also called elapsed or real time, is what a user waits from start to finish, including time spent waiting for disk, network or locks and time slices given to other programs. CPU time counts only the time a processor actually spent executing the program. On Unix-like systems the time command shows both: real is wall-clock time, while user and sys split CPU time into the program's own code and kernel work done on its behalf, such as system calls.
Comparing the two values shows where time goes. If wall-clock time is much larger than CPU time for a single-threaded program, it is mostly waiting, typically on I/O or locks, and a faster processor will help little. If CPU time is close to wall-clock time, the program is compute-bound. With several threads running in parallel, total CPU time can exceed wall-clock time: four threads each busy for 10 s give about 40 s of CPU time in about 10 s of elapsed time.
In computer architecture, the CPU time of a program is written as instruction count × CPI (average clock cycles per instruction) × clock period, or equivalently instruction count × CPI ÷ clock frequency. The equation separates the contributions of the compiler and instruction set (instruction count), the microarchitecture (CPI) and the circuit technology (clock rate). It also shows why improving one factor at the expense of another, such as raising frequency while CPI worsens, may not make a program faster.
Busy CPU time is not always useful work. A thread spinning on a lock that is held for a long time burns CPU time doing nothing, and on a single core it can even delay the lock holder until its time slice ends; long waits call for a mutex that sleeps. In real-time and automotive systems, CPU time is allocated and monitored per task, and temporal partitioning ensures a misbehaving lower-criticality task cannot consume the execution time that safety-critical software needs.
Answer: A. Wall-clock time is the actual elapsed time from start to finish, including I/O waits; CPU time counts only time the CPU spent executing the program
Wall-clock time is what the user actually waits, including time spent waiting for disk or network and time yielded to other programs. CPU time is the total time the CPU spent executing the program's instructions. If wall-clock time is much longer than CPU time, a lot of time is spent waiting. Conversely, with multiple threads running in parallel, total CPU time can exceed wall-clock time.
The program used several threads or processes running simultaneously on different cores, and CPU time adds up the time on all of them. Four fully busy threads, for example, accumulate roughly four seconds of CPU time per second of elapsed time.
Real is elapsed wall-clock time, user is CPU time spent in the program's own code, and sys is CPU time the kernel spent on its behalf, such as handling system calls.
No. While a program waits for disk or network it is not executing, so that time appears in wall-clock time but not in CPU time.
CPU time appears in 5 practice questions across 5 topics, including Performance Analysis, Automotive Semiconductors and Functional Safety, CPUs and architecture.
As an Amazon Associate I earn from qualifying purchases.
This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.