Skip to content

9618 · Unit 16 · Paper 3: Advanced theory

Processors, parallel systems and virtual machines.

9618 · Unit 16 · Processors, parallel systems and virtual machines
Revisionbyexamplicity

RISC and CISC

§15.1 · Processors, parallel processing and virtual machines

Every processor understands its own fixed set of instructions, and designers disagree about how much each one should do. An instruction set architecture defines instructions, formats, addressing modes and accessible registers. A Reduced Instruction Set Computer (RISC) uses simpler instructions; a Complex Instruction Set Computer (CISC) includes more complex operations.

Take one small job: brighten a tile of four pixels by adding 6 to each. Either design must turn the input tile into the same output tile; what differs is how many instructions that takes, and how long each one runs.

Input tile14365882Output tile20426488add 6

Compare typical design features

Read one row at a time: each compares the two designs on a single feature. Most rows follow from one choice, simple instructions or powerful ones.

Typical designRISCCISC
InstructionsSmaller, simpler set; usually fixed-length instructions.Larger set with complex operations; lengths/formats can vary.
Addressing and memoryFew addressing modes; load/store instructions transfer data between memory and registers.More addressing modes; some operations work directly on memory operands.
RegistersMany general-purpose registers hold intermediate operands.Typically fewer general-purpose registers; more work may involve memory.
Control unitUsually hard-wired control: circuits generate control signals directly.Often microprogrammed control: stored microinstructions sequence the smaller operations.
ExecutionSimple, regular stages ease pipelining; many operations complete in one cycle.A complex instruction may require several cycles and more complex control.

Do fewer instructions mean less time?

  • A simple design may load a pixel into a register, add 6, then store it.
  • A complex instruction may combine more of that work in one instruction.
  • Fewer program instructions do not by themselves prove a shorter execution time: cycles per instruction and clock rate also matter.
Your turn

1 Which design usually has fixed-length instructions and many general-purpose registers?

2 Which design is often microprogrammed?

3 A RISC program for the tile has more instructions than a CISC one. Must it take longer? Give a reason.

  1. 1
    RISC
  2. 2
    CISC
  3. 3
    no: the time also depends on the cycles each instruction needs and on the clock rate; simple one-cycle instructions can finish sooner
Tick what you can do now
Practise with w24/31 Q2; s24/31 Q11(a); w24/32 Q8 (older papers: RISC and CISC features)
1 / 7
9618 · Unit 16 · Processors, parallel systems and virtual machines
Revisionbyexamplicity

Pipelining

§15.1 · Processors, parallel processing and virtual machines

Without overlap, most of a processor sits idle. Pipelining overlaps stages from different instructions. While one instruction executes, others can be decoded or fetched using different stage hardware and intermediate registers.

A, B, C and D independently add 6 to four pixels. No stage handles two instructions in one cycle.

Each instruction has five one-cycle stages: instruction fetch (IF), instruction decode (ID), operand fetch (OF), instruction execute (IE) and write back (WB).

Each cycle, every instruction moves one stage along. The strip under the stages records which instruction sat in each stage, cycle by cycle.

End of cycle 8: all four instructions completedIFIDOFIEWBABCDcompletedStage occupancy by cycle12345678IFABCDIDABCDOFABCDIEABCDWBABCD

Count the cycles: latency and throughput

Without overlap: 4 × 5 = 20 cyclesEach instruction finishes all five stages before the next starts.With this pipeline: 5 + 3 = 8 cyclesFill the five stages, then complete one instruction each following cycle.First instruction still takes 5 cyclesLatency is the time for one instruction; throughput is the rate of completions.

Read the schedule one cycle at a time

One row per clock cycle; each instruction sits in the column of the stage it uses. Find the cycle where the first instruction completes.

IFIDOFIEWBWhat happens
cycle 1A1 A enters IF
1 A enters IF
cycle 2BAB enters IF
B enters IF
cycle 3CBAC enters IF
C enters IF
cycle 4DCBAD enters IF
D enters IF
cycle 5DCBA2 A completes
2 A completes
cycle 6DCBB completes
B completes
cycle 7DCC completes
C completes
cycle 8DD completes
D completes
  1. 1
    Cycles 1 to 4 fill the pipeline: one new instruction enters IF each cycle.
  2. 2
    From cycle 5 one instruction completes every cycle. A still took 5 cycles (latency); D completes in cycle 8.

Registers hold the work between stages

Overlap works only if each instruction’s half-finished work has somewhere to wait while the next stage is busy.

  • Each stage passes its result into a pipeline register, so the next stage can use it in the following cycle.
  • Each instruction keeps its own intermediate state, rather than overwriting the state of the instruction ahead.

What can stop a full pipeline

One completion per cycle holds only while every instruction can move on. Each of these breaks that.

  • If B needs A’s result before it is available, B may have to stall.
  • A branch can make already fetched instructions irrelevant.
  • Interrupt handling must identify which instructions have completed and which must be restarted.
Your turn

1 Six independent instructions use this five-stage pipeline. How many cycles without overlap, and with it?

2 In cycle 4, which instruction is in OF?

3 What is the difference between latency and throughput?

  1. 1
    30 without overlap (6 × 5); 10 with it (5 + 5)
  2. 2
    B
  3. 3
    latency is the time for one instruction (5 cycles); throughput is the rate of completions (one per cycle once full)
Tick what you can do now
Practise with s23/32 Q8(b) (older paper: pipeline schedule)
2 / 7
9618 · Unit 16 · Processors, parallel systems and virtual machines
Revisionbyexamplicity

Interrupt handling in a pipeline

§15.1 · Processors, parallel processing and virtual machines

A finished disk transfer can need the processor at any moment, and the program must carry on afterwards as if nothing happened. An interrupt requests processor attention. The processor must preserve a consistent program state before its interrupt service routine (ISR) can use the registers; a pipeline adds unfinished instructions to manage.

Take the image job’s pipeline of A, B, C and D. An I/O completion interrupt is accepted when A writes back 20. B, C and D are still in earlier stages. Only A’s result has changed the program’s stored state.

After the ISR · resume the image jobIFIDOFIEWBACommitted A = 20B, C, D discardedSaved program state · stackA = 20 · restart PC = B · registers / flagsCPU registers / PCRestored: A = 20 · PC = B · original flagsBRefetched B12345

Preserve the restart address, registers and flags

Each point matches a numbered mark on the figure. Step through it with Motion on.

  1. 1
    A has written back 20: it is committed. Restarting A would incorrectly add 6 twice.
  2. 2
    B, C and D are unfinished: flush them and discard their partial work.
  3. 3
    Save the restart PC (B) and the program registers/flags on the stack before loading the ISR address.
  4. 4
    The ISR uses the CPU registers. Afterwards restore the saved state, so B resumes with the original operands.
  5. 5
    Refetch B into IF; C and D follow it.

Why a pipeline makes interrupts harder

  • Without overlap, a processor can finish its current instruction before saving the next address.
  • In a RISC pipeline, several instructions may be partly processed at once.
  • Clearing that unfinished work and refilling the pipeline costs cycles, but prevents partial results or skipped instructions from corrupting the resumed image job.
Your turn

1 Why must A not run again after the ISR?

2 What is saved on the stack before the ISR starts?

3 Which instruction is fetched first after the ISR, and why?

  1. 1
    it has already written back 20; running it again would add 6 twice
  2. 2
    the restart PC, the registers and the flags (the program state)
  3. 3
    B: it was the oldest unfinished instruction, so its partial work was flushed and it starts again
Tick what you can do now
Practise with s24/31 Q11(b–c) (older paper: interrupt handling and RISC pipeline)
3 / 7
9618 · Unit 16 · Processors, parallel systems and virtual machines
Revisionbyexamplicity

SISD, SIMD, MISD and MIMD

§15.1 · Processors, parallel processing and virtual machines

Once there are several processors, the question is what each one is doing. Count instruction streams and data streams separately: the same number of processors can be organised to do the same operation on different data, or different operations on the same data.

In each drawing, find what the processors share: one instruction (SIMD), one piece of data (MISD), or nothing at all (MIMD).

SISD

ADD 6Processor20One data stream: 14, 36, 58, 82One instruction stream acts in sequence.

Single Instruction, Single Data: one processor follows one instruction stream on one data stream.

SIMD

ADD 6Processor 114 → 20Processor 236 → 42

Single Instruction, Multiple Data: processors apply the same instruction simultaneously to different data elements.

MISD

Same tileBrightenProcessor 1Check rangeProcessor 2

Multiple Instruction, Single Data: processors apply different instruction streams to the same input stream. This is a conceptual organisation with limited practical use.

MIMD

Tile ABrightenProcessor 1Tile BFind edgesProcessor 2

Multiple Instruction, Multiple Data: processors independently follow different instruction streams on different data.

Count the streams for each class

Name the class by counting the two streams, then say what the processors are doing in the image job.

ClassInstruction streamsData streamsIn the image job
SISDoneoneone processor brightens each pixel in turn
SIMDone, sharedmanyADD 6 applied to four pixels at once
MISDmanyone, sharedbrighten and check range on the same tile
MIMDmanymanybrighten tile A while finding edges in tile B
Pipelining overlaps instruction stages. SIMD instead applies one instruction across several data elements. A processor can use both techniques.
Your turn

1 One instruction adds 6 to four pixels at the same time. Which class?

2 Two processors run different programs on different tiles. Which class?

3 What do the processors share in MISD, and what differs?

  1. 1
    SIMD
  2. 2
    MIMD
  3. 3
    they share one data stream; their instruction streams differ
Tick what you can do now
Practise with s26/33 Q4(b)
4 / 7
9618 · Unit 16 · Processors, parallel systems and virtual machines
Revisionbyexamplicity

Massively parallel systems

§15.1 · Processors, parallel processing and virtual machines

Brightening a huge image one tile at a time would take far too long on one processor. A massively parallel computer links a very large number of processors so they work simultaneously on parts of one overall problem. Their results must be communicated and combined.

A large image contains 4096 tiles. With 1024 processors, an even division gives 4 tiles per processor. The three chips in the drawing stand for all 1024: follow the work from the whole image, through the processors, into one output.

4096 image tilesshared by 1024 processorsProcessorlocal tilesProcessorlocal tilesProcessorlocal tilesCombine tiles into output

What the system must provide

Processors alone do not make a parallel system. Read down the stages in the order the job runs, and what each one needs.

Stage of the image jobWhat the system must provide
DivideAssign each processor its tile data and instructions; balance the work so processors do not wait for one slow part.
Process togetherProcessors handle their assigned parts simultaneously. Local memories or shared memory supply the operands.
CommunicateInterconnected pathways or a network carry data and results. Neighbour-dependent filters must exchange edge pixels.
CombinePut finished tiles back in the correct positions; coordinate completion before using the complete image.

Why more processors are not always faster

  • Independent brightness changes distribute easily.
  • Sending tiles, synchronising processors and combining results take time; a serial part still runs in sequence.
  • Adding processors cannot remove those costs, and may increase communication.
  • A cluster links separate computers to cooperate; massively parallel systems may use distributed or shared-memory arrangements.
Your turn

1 8192 tiles are shared evenly by 1024 processors. How many tiles does each processor get?

2 Give one reason why doubling the processors does not halve the time.

3 Besides the processors themselves, name two things a massively parallel system must provide.

  1. 1
    8
  2. 2
    sending data, synchronising and combining results take time, and a serial part still runs in sequence
  3. 3
    any two of: a way to divide and assign the work, communication pathways between processors, a way to combine the results
Tick what you can do now
Practise with s26/33 Q4(a)
5 / 7
9618 · Unit 16 · Processors, parallel systems and virtual machines
Revisionbyexamplicity

Virtual machines and their host

§15.1 · Processors, parallel processing and virtual machines

One computer can act as several. A system virtual machine (VM) is a software-provided computer environment. Its guest operating system uses virtual hardware, while a physical host supplies the real processing, memory and storage.

The image team runs the production tool and a test build in separate guest systems. In this hosted arrangement, the hypervisor runs above a host operating system.

Read the drawing from the top down: each layer works only through the one beneath it.

ONE PHYSICAL HOSTGuest A · image toolGuest OS AVirtual CPU / RAMGuest B · test buildGuest OS BVirtual CPU / RAMHypervisor · creates VMs, allocates resourcesHost operating systemPhysical CPU · memory · storage1234

Follow a guest request down to the hardware

  1. 1
    The image tool asks its guest OS to save a tile.
  2. 2
    The guest OS addresses a virtual disk.
  3. 3
    The hypervisor maps that virtual resource to storage supplied by the host.
  4. 4
    The host controls access to the physical device. A guest’s “processor” is an allocated view of the host’s processor resources.
  • The guests can use different operating systems on one physical computer.
  • Some virtual-machine software can emulate a different instruction set, at additional cost.
A process VM, such as a language runtime, supports a program’s execution environment. It does not provide an entire guest computer and guest operating system as a system VM does.
Your turn

1 What does the hypervisor do?

2 Put in order for saving a tile: hypervisor, image tool, physical storage, guest OS.

3 Give one difference between a system VM and a process VM.

  1. 1
    it creates the virtual machines, allocates the host’s resources to them and maps virtual hardware to real hardware
  2. 2
    image tool, guest OS, hypervisor, physical storage
  3. 3
    a system VM provides a whole guest computer with its own OS; a process VM only provides an environment for one program
Tick what you can do now
Practise with s26/32 Q5
6 / 7
9618 · Unit 16 · Processors, parallel systems and virtual machines
Revisionbyexamplicity

Virtual-machine benefits and limits

§15.1 · Processors, parallel processing and virtual machines

A VM is worth having when a job needs a separate machine but not a separate computer. Judge it against the image job’s requirements: isolation and compatibility are useful, but the guests still depend on the same finite host resources.

Each row starts from something the image team needs. Read the benefit, then the condition that must hold for it to be true.

RequirementBenefit of a VMCondition or cost
Test a new image-tool buildA test guest can fail while the production guest continues; separate environments reduce interference.Isolation depends on correct configuration; it does not add physical capacity.
Keep an older image toolA compatible guest OS can run software unsuitable for the host OS.Required hardware/software support must be available; not every device can be emulated.
Try several operating systemsSeparate guests can use one host, avoiding a physical computer for each test environment.Virtualisation and managing the guests add work and overhead.
Move a prepared environmentThe virtual hardware interface can make the environment easier to reproduce on a compatible host.The new host must provide sufficient resources and compatible VM support.

Share out the host’s RAM

Every guest’s memory comes out of the host’s own RAM.

Every guest’s memory comes out of the host’s own RAM. Compare where each bar ends with the dashed line where physical RAM runs out.

Fitshost 4guest A 6guest B 6Askshost 4guest A 8guest B 8physical RAM ends at 16 GB20 GB

Host capacity → 16 GB of physical RAM.

Allocation → 4 GB for the host and 6 GB for each of two guests: 4 + 6 + 6 = 16 GB.

Extra demand → giving both guests 8 GB would request 4 + 8 + 8 = 20 GB; physical RAM has not increased.

  • Insufficient RAM or competing CPU work can degrade performance.
  • Accessing hardware indirectly adds overhead, and a host failure can affect every guest on it.
  • A VM suits testing and compatibility; direct hardware access may better suit a performance-critical image run when isolation is less important.

Pipelining, parallel processing or virtualisation?

These three ideas are easy to mix up, because each seems to do more at once.

  • Pipelining overlaps instruction stages.
  • Parallel processing divides work between processors.
  • Virtualisation divides or emulates machine environments. Creating more VMs alone does not create more physical processors.
Your turn

1 The host has 16 GB and keeps 4 GB for itself. Can it give three guests 4 GB each?

2 Give one benefit of testing a new build in a VM.

3 Does creating more VMs give the host more processing power?

  1. 1
    yes: 4 + 3 × 4 = 16 GB, which is not more than 16 GB
  2. 2
    if the test guest fails, the production guest keeps running
  3. 3
    no: every guest shares the same physical processors and memory
Tick what you can do now
Practise with s26/31 Q5
7 / 7