Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating Systems Chapter 5: Input/Output Management

Similar presentations


Presentation on theme: "Operating Systems Chapter 5: Input/Output Management"— Presentation transcript:

1 Operating Systems Chapter 5: Input/Output Management
Instr: Yusuf Altunel IKU Department of Computer Engineering

2 Content Principles of I/O hardware Principles of I/O software
I/O Devices Device Controllers Direct Memory Access Interrupts Principles of I/O software Programmed I/O Interrupt Driven I/O I/O Using DMA

3 Introduction OS Functions The I/0 codes represent
to control all the computer’s I/O (Input/Output) devices issue commands to the devices catch interrupts handle errors to provide an interface to the devices device independence: the interface should be the same for all devices The I/0 codes represent a significant fraction of the total operating system

4 I/O Hardware block devices stores information Common block sizes:
in fixed-size blocks, each one with its own address. Common block sizes: range from 512 bytes to 32,768 bytes. it is possible to ‘read or write data blocks independently of all the other ones. Disks are the most common block devices

5 I/O Hardware character devices delivers or accepts
a stream of characters, no block structure is available. It is not addressable does not have any seek operation. Examples: printers, network interfaces, mouse,

6 Some device, network, and data base rates
Speed Some device, network, and data base rates

7 Device Controllers I/O devices have components: device controller
mechanical component electronic component device controller the electronic component can handle multiple devices Controller's tasks convert serial bit stream to block of bytes perform error correction make data available to transfer it to main memory

8 Memory-Mapped I/O Devices addressed independent of the memory
Devices are addressed in common address space A hybrid approach

9 Bus Architecture (a) A single-bus architecture
(b) A dual-bus memory architecture

10 Direct Memory Access CPU must be able DMA (Direct Memory Access)
to address the device controllers to exchange data with them DMA (Direct Memory Access) memory address register The memory address to be used in DMA operation a byte count register The amount of bytes to transfer one or more control registers to identify the I/O port to use the direction of the transfer unit: bytes or words the number of bytes to transfer in one burst

11 DMA Transfer Operations of DMA Transfer

12 Interrupts When an I/O device finishes its job interrupts can be
it causes an interrupt by asserting a signal on a hits line This signal is detected by the interrupt controller a chip on the main board interrupts can be enabled or disabled by the operating system If no other interrupts are pending process the interrupt immediately. If another one is in progress the device is just ignored for the moment it continues to assert until it is serviced by the CPU Pending: Askıda

13 How an Interrupt Happens
Connections between devices and interrupt controller actually use interrupt lines on the bus rather than dedicated wires

14 Handling Interrupts To handle the interrupt,
the controller puts a number on the address lines for the address of the device The interrupt signal causes the CPU to stop what it is doing and start doing something else. The number on the address lines is used as an index into a table called the interrupt vector to fetch a new program counter. program counter points to the interrupt service procedure.

15 I/O Software Device independence Uniform naming Error handling
programs can access any I/O devices without specifying device in advance floppy, hard drive, CD-ROM ... Uniform naming device name must be machine-independent Error handling handle erorrs as close to the hardware

16 I/O Software Synchronous vs. asynchronous transfers Buffering
blocked transfers interrupt-driven transfers Buffering data coming from a device cannot be stored in final destination Sharable vs. dedicated devices disks are sharable tape drives can not be shared

17 I/O Types Programmed I/O Interrupt-driven I/O I/O using DMA

18 Programmed I/O user process to print string “ABCDEFGH” on the printer:
assemble the string in a buffer in user space acquire the printer for writing by making a system call to open it If the printer is currently in use fail and return an error code or will block until the printer is available make the system call to print the string on the printer

19 Programmed I/O Operating System copies the buffer checks to see
to an array in kernel space checks to see if the printer is available If not, it waits until it is available copies the first character to the printer’s data register if the printer is ready to accept another one when ready, it prints the next character

20 Steps in Printing a String

21 Interrupt-Driven I/O to allow the CPU In case of system call
do something else while waiting for device In case of system call to print the string is made, the buffer is copied to kernel space, as soon as the printer becomes ready the first character is copied to the printer cuncerrently., CPU calls the scheduler to run some other processes The process printing the string is blocked until the entire string has printed.

22 Example: Writing a string to the printer using interrupt-driven I/O
Code executed when print system call is made Interrupt service procedure

23 I/O Using DMA Interrupts take time A solution is to use DMA
wastes CPU time A solution is to use DMA let the DMA controller feed the characters to the printer one at time without bothering the CPU DMA is programmed I/O the DMA controller is doing all the work instead of the main CPU

24 Disadvantages DMA controller is If then much slower than the main CPU.
the DMA controller is not capable of driving the device at full speed or the CPU usually has nothing to do while waiting for the DMA interrupt then interrupt-driven I/O or even programmed I/O may be better

25 Input/Output Management
End of Chapter 5 Input/Output Management


Download ppt "Operating Systems Chapter 5: Input/Output Management"

Similar presentations


Ads by Google