Course 3.1Lesson 3 of 3
Why is one processor faster than another? This lesson explains how the clock, the number of cores and the size of the cache change performance. It then explains the instruction set of a CPU, and what makes an embedded system different from a general purpose computer.
Try the code and the simulations beside the lesson.
Two laptops can run the same program at different speeds. Three parts of the CPU make most of the difference: the clock, the cores and the cache. The number of cores, the size of the cache and the speed of the clock can all affect the performance of a CPU.
The clock sends out a regular signal. Each tick starts the next small step of work, so every part of the CPU keeps in time.
The clock speed is the number of clock cycles in one second. It is measured in hertz (Hz). One hertz is one cycle each second. A clock of (gigahertz) ticks 3 billion times each second.
A faster clock means more cycles each second, so more instructions can be carried out in the same time. A task of 12 billion cycles takes seconds at , and seconds at .
A core is one complete processing unit, with its own ALU, control unit and registers. Each core can fetch, decode and execute instructions on its own. A dual-core CPU has two cores. A quad-core CPU has four.
More cores means more instructions can be processed at the same time. But it does not always mean a proportional increase in speed. Some parts of a task must be done in order, one step after another, and only one core can do them. The cores also spend some time sharing out the work. So two cores do not always make a program twice as fast.
Cache is a small amount of very fast memory, in or very close to the CPU. It holds instructions and data that the CPU uses often, or is likely to use next. Fetching from cache is much quicker than fetching from RAM.
A larger cache can hold more of these instructions and data. Then the CPU finds what it needs in the cache more often and waits for RAM less often. So performance improves.
The picture shows a CPU with four cores. Each core has its own small cache, and the cores share a larger cache. RAM is further away, outside the CPU.
Every CPU understands a fixed list of commands. This list is its instruction set. An instruction set is a list of all the commands that can be processed by a CPU, and the commands are machine code.
The LOAD, ADD, STORE and STOP of this course are a made-up instruction set. A real CPU has many more commands, each one a pattern of binary digits. A program must be in the machine code of the CPU that will run it.
A washing machine has a processor. So does a car, a burglar alarm and a vending machine. None of them is a general purpose computer.
An embedded system is a computer system built into a larger device, to perform a dedicated function. The program of a washing machine only runs washes. It will not run a game.
The program uses a simple model. Each core does one instruction in each clock cycle. Three quarters of the work can be shared between cores, and the rest cannot. It prints the time at two clock speeds and four numbers of cores.
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Every lesson is open to read. Enrolling also lets you:
Log in to join the discussion.
Loading…
This lesson is free to read. Enroll free to keep your place and take the tests.