Presentation is loading. Please wait.

Presentation is loading. Please wait.

Block I/O. 2 Definition Any I/O operation in which the unit of data is several words, not just one word or byte.

Similar presentations


Presentation on theme: "Block I/O. 2 Definition Any I/O operation in which the unit of data is several words, not just one word or byte."— Presentation transcript:

1 Block I/O

2 2 Definition Any I/O operation in which the unit of data is several words, not just one word or byte.

3 3 Example Disc I/O is usually done in blocks of 512 bytes (half a Kbyte) If the CPU wants to read from disc, it must tell the disc driver which block it wants. When the disc-read operation is complete, the whole block is available for immediate reading.

4 4 Usage Block I/O is used for any peripheral that transfers large amounts of data at high speed, e.g. Hard disc CD-ROM/DVD Graphics card Network connection (ethernet)

5 5 Lots of Block I/O A typical computer does a great deal of block I/O. For example: Loading programs into memory Swapping things in and out of memory Reading and writing data files Network traffic

6 6 The Problem with Block I/O If all the data has to be transferred by the CPU, then 1.It takes too long 2.The CPU doesn’t do much else In short, bulk data transfer is a bottleneck

7 7 Programmed Data Transfer Consider the following (hypothetical) code fragment for transferring a block of data from an I/O port to memory: L1:MOV(R1),(R2)+ DECR3 BNEL1 Address of I/O data register Address of 1 st location in memory Number of words (remaining) to be transferred

8 8 The Problem with Block I/O L1:MOV(R1),(R2)+ DECR3 BNEL1 One iteration of the loop takes (at least) five bus cycles, and transfers only one word Data transfer rate: 0.2 words per cycle

9 9 Hardware Solution: DMA DMA = Direct Memory Access A DMA controller (DMAC) is a hardware device to which the CPU can delegate the task of doing block data transfers

10 10 DMA Advantages DMA is the fastest possible solution: transfer rate is 1 word per bus cycle The CPU can (sometimes) do something useful in the meantime Disadvantages DMA hardware is complicated

11 11 Example DMA Installation (this one dedicated to a single I/O port) CPUmemoryDMAC I/O port High-Bandwidth Peripheral bus

12 12 DMAC Internal Registers address count control status I/O port Next memory location to access Number of words (or bytes) to transfer Transfer direction (read or write) and other controls e.g. finished or error For DMACs that contain >1 port, which port

13 13 DMAC Programming Procedure 1.Load the memory start-of-block address into the address register 2.Load the amount to transfer into the count register 3.Specify the transfer direction (read from, or write to, memory) in the control register address count control status I/O port

14 14 DMAC Programming Procedure 4.Select the I/O port (if there is a choice) 5.Specify interrupt options in the control register (DMACs can be programmed to interrupt when they are finished) 6.Tell the DMAC to start address count control status I/O port

15 15 What the DMAC does 1.Request permission to take control of the bus (see next slide) 2.When permission is granted, perform one or more data transfer operations, using only one bus cycle per transfer 3.Relinquish control of the bus 4.Go back to 1 if block transfer is not complete NOTE: Exact details are complicated and hardware- specific

16 16 Getting Control of the Bus A handshake protocol involving two signals: Bus Request and Bus Grant

17 17 Test Yourself! 1.What is block I/O? Give some examples 2.What are the problems, from the CPU’s point of view, of block I/O? 3.What is the solution? 4.Explain the operation of the DMAC


Download ppt "Block I/O. 2 Definition Any I/O operation in which the unit of data is several words, not just one word or byte."

Similar presentations


Ads by Google