Preview A Level Computer Science for WJEC/Eduqas Student Book

Page 24

Chapter 10: Hardware and communication

Amdahl’s law is used to calculate the minimum runtime of executing a program on a certain number of threads: 1 T(n) = T(1) (B + n (1 – B) Where: •• •• ••

T(n) = time taken on n threads n = number of threads B = fraction of the algorithm that is sequential

As in the single-core example above, Amdahl’s law demonstrates that with one thread (n = 1), the runtime of executing the program is 5 hours: 1 T(n) = T(1) (B + n (1 – B) 1 T(1) – 5 hours × (0.2 + n (1 – 0.2)) – 5 hours

e

However, using Amdahl’s law to calculate the runtime in a quad-core processor with four threads (n = 4), you get:

pl

1 T(n) = T(1) (B + n (1 – B) 1 T(4) – 5 hours × (0.2 + (1 – 0.2)) – 2 hours 4

Note that even with an infinite number of threads, the runtime of executing the program cannot be less than 1 hour.

Sa m

Fetch-decode-execute cycle (FDE)

When instructions are to be executed by the processor, they must be loaded into the processor one after another, via a process known as the fetch-decode-execute cycle (FDE). In the previous section, you were introduced to a number of special purpose registers used during the FDE cycle and in this section you will see how they work together. It is important to remember that a single processor can only execute a single instruction at a time from the current instruction register. By using a large number of registers, the whole process can be made more efficient using a system called pipelining. Figure 10.2 shows a summary of the registers involved in the FDE cycle.

CPU

ACC

ACC – Accumulator register

MAR

MAR – Memory address register

PC

PC

– Program Counter

MDR

MDR – Memory data register

CIR

CIR – Current instruction register

Figure 10.2: Specialist registers used during FDE cycle.

In Figure 10.3, the address stored in the PC is 0092. The first part of the cycle is to fetch the next instruction for processing. The PC is copied over to the MAR and then the PC is incremented. Most programs will run serially, unless a control instruction such as a jump is encountered, so by incrementing the PC it is highly likely that it will be pointing to the next instruction to be fetched.

© Cambridge University Press 2017 The third party copyright material that appears in this sample may still be pending clearance and may be subject to change.

205


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
Preview A Level Computer Science for WJEC/Eduqas Student Book by Cambridge International Education - Issuu