Inside the CPU: Fetch, Decode, Execute
The cycle a processor repeats: fetch the next instruction from memory, work out what it means, carry it out. Clock speed, cores and cache each change how fast that goes.
What a learner can do afterwards
- Put the three stages of the cycle in order and say what each does
- Explain what a higher clock speed buys, and what extra cores buy
- Explain why both instructions and data sit in memory while a program runs
1 · Read
Your processor repeats one cycle: fetch the next instruction from memory, decode what it means, then execute it. Fetch, decode, execute, and round again. That loop runs every app you open, billions of times a second.
The ALU does the maths and comparisons during execute, once decode has spoken, using chains of AND, OR and NOT gates. Clock speed counts cycles per second, so 3 GHz means about 3 billion rounds each second.
A faster clock squeezes more rounds into each second, while extra cores run whole cycles side by side. Two cores are not always twice as fast, since some work refuses to split. Cache helps too: it shelves recent instructions nearby, and programs reuse the same bits so often that fetching flies.
Both instructions and data wait in memory during a run, since each fetch grabs the next order from there. Pushing clocks past stock speeds cooks extra heat, so speed always trades against cooling.
Fetch from memory, decode the meaning, execute the deed, and speed that loop with clocks, cores and cache.
The rewritten readings were written for this dataset.
More to read
Why computers use several memory layers
Fetching instructions and data can limit CPU performance. Computers therefore combine storage layers with different speeds and capacities.
Registers are tiny, fast storage locations within the CPU. Cache supplies a larger pool of fast memory, holding copies of recently used instructions and data. RAM holds more but takes longer to access. Disk storage offers much greater capacity with slower access still.
Programs often return to instructions and data they used moments earlier. This behaviour is called locality. Keeping those copies in cache reduces slower memory accesses and helps instruction processing proceed faster.
A larger cache or better cache management can improve performance while the processor's clock speed stays unchanged.
Terms for understanding instruction processing
During execution, the arithmetic logic unit, or ALU, performs arithmetic and logical operations, including comparisons.
An addressing mode specifies how an instruction obtains its operand. This may involve a memory address, but operands can also come from registers or the instruction itself.
An assembler translates readable assembly instructions into machine code the processor can run.
Abstraction lets programmers work without tracking every underlying detail. For many tasks, they can leave register and cache management to lower layers.
The processor first fetches a machine instruction. Decoding identifies the required operation and how to obtain its operands. Execution then carries out that operation.
The parts that run a program
Processors, main memory, disk storage and input/output devices cooperate to run programs.
High-level programming languages make code easier for people to read and write. A processor cannot directly execute that source code. Translation produces machine instructions, either before execution or as a program runs.
Memory stores instructions alongside data, and the processor fetches and executes instructions. Phones, laptops and large servers share this broad arrangement.
What a CPU's clock speed measures
Clock speed counts clock ticks per second, not complete fetch-decode-execute cycles. Gigahertz, or GHz, means billions of ticks each second: 3 GHz is about 3 billion. Instructions can take several ticks, and processors may handle several instructions during one tick.
Processor information is available through Windows Settings, About This Mac on macOS, and system-information tools on Linux. Whether clock speed appears there depends on the system; another information tool may be needed.
A faster clock can help instructions run faster. But equal clock speeds do not mean equal performance. Core count and cache also matter.
Overclocking and its risks
Overclocking raises a processor's clock frequency beyond its specified operating settings. It may also involve raising voltage.
More clock ticks each second can improve instruction throughput, although this does not guarantee faster performance for every task. Gamers and other users may overclock to get more performance from existing hardware.
Higher frequency and voltage usually increase heat. Adequate cooling is necessary, but cannot remove every risk. Excessive settings may cause unstable operation or damage the processor, including through excessive voltage.
The balance between possible speed gains, heat and reliability helps explain why clock frequency alone cannot describe a computer's performance.
2 · Watch
En anglaisTake it off screen
Where it sits
Learn first
Optional connections
8 questions wait behind this lesson, each with its answer explained. Every answer feeds the sky: stars light as they are learned, and dim when it is time to come back.