GoalExplain what a core is, why a single core works through instructions one at a time, and how extra cores help and sometimes have to wait.
New words
core · a processing unit inside a CPU that carries out one instruction at a timemulti-core CPU · a CPU with two or more cores, such as a dual core (two) or a quad core (four)idle · waiting with no instruction to carry out
Explanation
A core is a processing unit inside the CPU. One core follows one instruction at a time, like one worker with one pair of hands. A multi-core CPU has several cores, and each core can work on a different instruction at the same moment. This saves time when the jobs do not depend on each other. Even so, a program’s instructions are still arranged in order, because the order changes the answer and because some computers have only one core. Sometimes a core needs a result that another core has not finished yet, so it must sit idle and wait. This is why four cores do not always finish a program four times faster.
Single core
Dual core
Quad core
Cores
1
2
4
Instructions at the same moment
1
up to 2
up to 4
Can a core be idle?
only if there is nothing to do
yes, if it waits for a result
yes, if it waits for a result
Worked examples
Cores
Jobs for each core
Total time (seconds)
1
12
60
2
6
30
3
4
20
4
3
15
Twelve jobs that do not depend on each other. Each job takes 5 seconds. With one core, the jobs go one after another: 12 × 5 = 60 seconds. With two cores, each core takes 6 jobs, so 6 × 5 = 30 seconds. With three cores each takes 4 jobs (20 seconds) and with four cores each takes 3 jobs (15 seconds).
Core
0–2 s
2–4 s
4–7 s
Core 1
A
A
C
Core 2
B
idle
idle
A job that has to wait. Job A takes 4 seconds, job B takes 2 seconds, and job C takes 3 seconds but needs the results of both A and B. On one core the total is 4 + 2 + 3 = 9 seconds. On two cores, A and B run together, and C can only start when A has finished at 4 seconds, so the total is 4 + 3 = 7 seconds. Core 2 is idle from 2 seconds onwards.
Helpers
Total time (minutes)
1
12
2
6
3
6
4
6
More cores, no more speed. Four poster jobs take 3 minutes each: write the title, draw a border, colour the title letters, and stick on a photo. Colouring can only start after the title is written. One helper needs 4 × 3 = 12 minutes. Two helpers need 6 minutes (one writes and colours the title, one draws and sticks). Three or four helpers still need 6 minutes, because the title must be written before it is coloured.
Class activity
Copying race (no computer). You need a pencil, paper, a timer and a partner. Write a list of 12 short words. Job 1: one person copies all 12 words onto a new sheet; time it. Job 2: two people each copy 6 words onto the same sheet; time it. Job 3: the second person must write a number beside each word, but only after the first person has written that word. Time it. Compare your three times and say in which job the second person had to wait, and what that waiting is called.
Practice
1
Eight jobs do not depend on each other and each takes 3 seconds. Complete the table.
Cores
Jobs for each core
Total time (seconds)
1
?
?
2
?
?
4
?
?
One core: 8 × 3 = 24 s. Two cores: 4 jobs each, 12 s. Four cores: 2 jobs each, 6 s.
2
Job P takes 6 seconds and job Q takes 2 seconds, and they do not depend on each other. Job R takes 4 seconds and needs the results of both P and Q. Work out the total time on one core and on two cores. For how long is the second core idle?
Job
Time
Needs
P
6 s
nothing
Q
2 s
nothing
R
4 s
P and Q
One core: 6 + 2 + 4 = 12 s. Two cores: P and Q run together and take 6 s; R starts after 6 s and takes 4 s, so 10 s. Core 2 finishes Q at 2 s and is idle for the rest of the 10 s, which is 8 s.
3
Write true or false for each sentence and correct the false ones. (a) A quad core CPU always finishes a program four times faster than a single core. (b) A single core can carry out two instructions at the same moment. (c) A core may be idle while it waits for another core.
(a) False: cores sometimes wait for each other, so the gain is often smaller. (b) False: a single core carries out one instruction at a time. (c) True.
4
A learner says, “My new CPU has two cores, so every program will run in half the time.” Explain why this may not be true. Use an example from this lesson.
Only jobs that do not depend on each other can run at the same time. If one job needs the result of another, a core must wait idle. Example: in the poster jobs, colouring needs the title first, so more helpers could not make the poster faster than 6 minutes.