RISC and CISC
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.
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 design | RISC | CISC |
|---|---|---|
| Instructions | Smaller, simpler set; usually fixed-length instructions. | Larger set with complex operations; lengths/formats can vary. |
| Addressing and memory | Few addressing modes; load/store instructions transfer data between memory and registers. | More addressing modes; some operations work directly on memory operands. |
| Registers | Many general-purpose registers hold intermediate operands. | Typically fewer general-purpose registers; more work may involve memory. |
| Control unit | Usually hard-wired control: circuits generate control signals directly. | Often microprogrammed control: stored microinstructions sequence the smaller operations. |
| Execution | Simple, 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.
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.
- 1RISC
- 2CISC
- 3no: the time also depends on the cycles each instruction needs and on the clock rate; simple one-cycle instructions can finish sooner
Pipelining
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.
Count the cycles: latency and throughput
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.
| IF | ID | OF | IE | WB | What happens | |
|---|---|---|---|---|---|---|
| cycle 1 | A | 1 A enters IF | ||||
| 1 A enters IF | ||||||
| cycle 2 | B | A | B enters IF | |||
| B enters IF | ||||||
| cycle 3 | C | B | A | C enters IF | ||
| C enters IF | ||||||
| cycle 4 | D | C | B | A | D enters IF | |
| D enters IF | ||||||
| cycle 5 | D | C | B | A | 2 A completes | |
| 2 A completes | ||||||
| cycle 6 | D | C | B | B completes | ||
| B completes | ||||||
| cycle 7 | D | C | C completes | |||
| C completes | ||||||
| cycle 8 | D | D completes | ||||
| D completes | ||||||
- 1Cycles 1 to 4 fill the pipeline: one new instruction enters IF each cycle.
- 2From 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.
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?
- 130 without overlap (6 × 5); 10 with it (5 + 5)
- 2B
- 3latency is the time for one instruction (5 cycles); throughput is the rate of completions (one per cycle once full)
Interrupt handling in a pipeline
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.
Preserve the restart address, registers and flags
Each point matches a numbered mark on the figure. Step through it with Motion on.
- 1A has written back 20: it is committed. Restarting A would incorrectly add 6 twice.
- 2B, C and D are unfinished: flush them and discard their partial work.
- 3Save the restart PC (B) and the program registers/flags on the stack before loading the ISR address.
- 4The ISR uses the CPU registers. Afterwards restore the saved state, so B resumes with the original operands.
- 5Refetch 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.
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?
- 1it has already written back 20; running it again would add 6 twice
- 2the restart PC, the registers and the flags (the program state)
- 3B: it was the oldest unfinished instruction, so its partial work was flushed and it starts again
SISD, SIMD, MISD and MIMD
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
Single Instruction, Single Data: one processor follows one instruction stream on one data stream.
SIMD
Single Instruction, Multiple Data: processors apply the same instruction simultaneously to different data elements.
MISD
Multiple Instruction, Single Data: processors apply different instruction streams to the same input stream. This is a conceptual organisation with limited practical use.
MIMD
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.
| Class | Instruction streams | Data streams | In the image job |
|---|---|---|---|
| SISD | one | one | one processor brightens each pixel in turn |
| SIMD | one, shared | many | ADD 6 applied to four pixels at once |
| MISD | many | one, shared | brighten and check range on the same tile |
| MIMD | many | many | brighten tile A while finding edges in tile B |
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?
- 1SIMD
- 2MIMD
- 3they share one data stream; their instruction streams differ
Massively parallel systems
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.
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 job | What the system must provide |
|---|---|
| Divide | Assign each processor its tile data and instructions; balance the work so processors do not wait for one slow part. |
| Process together | Processors handle their assigned parts simultaneously. Local memories or shared memory supply the operands. |
| Communicate | Interconnected pathways or a network carry data and results. Neighbour-dependent filters must exchange edge pixels. |
| Combine | Put 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.
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.
- 18
- 2sending data, synchronising and combining results take time, and a serial part still runs in sequence
- 3any two of: a way to divide and assign the work, communication pathways between processors, a way to combine the results
Virtual machines and their host
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.
Follow a guest request down to the hardware
- 1The image tool asks its guest OS to save a tile.
- 2The guest OS addresses a virtual disk.
- 3The hypervisor maps that virtual resource to storage supplied by the host.
- 4The 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.
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.
- 1it creates the virtual machines, allocates the host’s resources to them and maps virtual hardware to real hardware
- 2image tool, guest OS, hypervisor, physical storage
- 3a system VM provides a whole guest computer with its own OS; a process VM only provides an environment for one program
Virtual-machine benefits and limits
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.
| Requirement | Benefit of a VM | Condition or cost |
|---|---|---|
| Test a new image-tool build | A 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 tool | A 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 systems | Separate 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 environment | The 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.
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.
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?
- 1yes: 4 + 3 × 4 = 16 GB, which is not more than 16 GB
- 2if the test guest fails, the production guest keeps running
- 3no: every guest shares the same physical processors and memory