CSC 322 Operating Systems Concepts Lecture - 23: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,

Slides:



Advertisements
Similar presentations
Input and Output CS 215 Lecture #20.
Advertisements

CS-334: Computer Architecture
Avishai Wool lecture Introduction to Systems Programming Lecture 8 Input-Output.
EEE 435 Principles of Operating Systems Principles and Structure of I/O Software (Modern Operating Systems 5.2 & 5.3) 5/22/20151Dr Alain Beaulieu.
Avishai Wool lecture Introduction to Systems Programming Lecture 8 Paging Design Input-Output.
04/16/2010CSCI 315 Operating Systems Design1 I/O Systems Notice: The slides for this lecture have been largely based on those accompanying an earlier edition.
1 COMP541 Interrupts, DMA, Serial I/O Montek Singh April 24, 2007.
1 Input/Output Chapter 3 TOPICS Principles of I/O hardware Principles of I/O software I/O software layers Disks Clocks Reference: Operating Systems Design.
1 Today I/O Systems Storage. 2 I/O Devices Many different kinds of I/O devices Software that controls them: device drivers.
Chapter 5 Input/Output I/O Hardware I/O Software Software Layers Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights.
Group 7 Jhonathan Briceño Reginal Etienne Christian Kruger Felix Martinez Dane Minott Immer S Rivera Ander Sahonero.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
1 Computer System Overview Chapter 1 Review of basic hardware concepts.
Copyright ©: Nahrstedt, Angrave, Abdelzaher
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
Input / Output CS 537 – Introduction to Operating Systems.
Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower.
1 Input/Output. 2 Principles of I/O Hardware Some typical device, network, and data base rates.
Chapter 7 Input/Output Luisa Botero Santiago Del Portillo Ivan Vega.
Chapter 10: Input / Output Devices Dr Mohamed Menacer Taibah University
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
CSC 322 Operating Systems Concepts Lecture - 3: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
CSC 322 Operating Systems Concepts Lecture - 4: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
1 CS503: Operating Systems Spring 2014 Dongyan Xu Department of Computer Science Purdue University.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 8-1: I/O Management Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
NETW 3005 I/O Systems. Reading For this lecture, you should have read Chapter 13 (Sections 1-4, 7). NETW3005 (Operating Systems) Lecture 10 - I/O Systems2.
CSC 322 Operating Systems Concepts Lecture - 25: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Interrupts and DMA CSCI The Role of the Operating System in Performing I/O Two main jobs of a computer are: –Processing –Performing I/O manage and.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Principles of I/0 hardware.
2007 Oct 18SYSC2001* - Dept. Systems and Computer Engineering, Carleton University Fall SYSC2001-Ch7.ppt 1 Chapter 7 Input/Output 7.1 External Devices.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Computer Architecture Lecture10: Input/output devices Piotr Bilski.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Input/Output CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent University.
1 Chapter 2: Computer-System Structures  Computer System Operation  I/O Structure  Storage Structure  Storage Hierarchy  Hardware Protection  General.
2009 Sep 10SYSC Dept. Systems and Computer Engineering, Carleton University F09. SYSC2001-Ch7.ppt 1 Chapter 7 Input/Output 7.1 External Devices 7.2.
Fall 2000M.B. Ibáñez Lecture 25 I/O Systems. Fall 2000M.B. Ibáñez Categories of I/O Devices Human readable –used to communicate with the user –video display.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem.
12/8/20151 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam King,
The computer system’s I/O architecture is its interface to the outside world. This architecture provides a systematic means of controlling interaction.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Chapter 5 Input/Output 5.1 Principles of I/O hardware
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 4 Computer Systems Review.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
Processor Memory Processor-memory bus I/O Device Bus Adapter I/O Device I/O Device Bus Adapter I/O Device I/O Device Expansion bus I/O Bus.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 2, 2005 I/O through system calls Protection.
Input Output Techniques Programmed Interrupt driven Direct Memory Access (DMA)
بسم الله الرحمن الرحيم MEMORY AND I/O.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
I/O Management.
Chapter 13: I/O Systems Modified by Dr. Neerja Mhaskar for CS 3SH3.
CSC 322 Operating Systems Concepts Lecture - 12: by
Operating Systems (CS 340 D)
CS703 - Advanced Operating Systems
CSCI 315 Operating Systems Design
© CHAROTAR INSTITUTE OF TECHNOLOGY, CHANGA
Operating Systems Chapter 5: Input/Output Management
Today’s agenda Hardware architecture and runtime system
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Chapter 13: I/O Systems.
Chapter 5 Input/Output Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

CSC 322 Operating Systems Concepts Lecture - 23: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. (Chapter-5) Silberschatz, Galvin and Gagne 2002, Operating System Concepts, Ahmed Mumtaz Mustehsan, CIIT, Islamabad

Chapter 5 Input/ Output Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad2

OS controls I/O devices => Issue commands, handles interrupts, handles errors Provide easy to use interface to devices Hopefully device independent First look at hardware, then software Emphasize software Software structured in layers Look at disks Overview Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad3

Some typical device network, and bus data rates. I/O Devices Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad4

Two types of I/O devices- block, character Block Can read blocks independently of one another Hard disks, CD-ROMs, USB sticks 512 to 32,768 bytes Character Accepts stream of characters without block structure Printers, mice, network interfaces Not everything fits, e.g. clocks don’t fit Division allows for OS to deal with devices in device independent manner File system deals with blocks Overview Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad5

A is track, B is sector, C is geometrical sector, D is cluster Disk geometry Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad6

I/O unit has 2 components-mechanical, electronic (controller) Controller is a chip with a connector which plugs into cables to device sometimes more than one of identical devices like SCSI controllers can handle 8 drives including (CD drive) Disk Disk might have 10,000 sectors of 512 bytes per track or different spec. Serial bit stream comes off drive Has preamble 4096 bits/sector, error correcting code Preamble has sector number, cylinder number, sector size…. Device Controllers Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad7

Controller assembles block from bit stream, does error correction, puts into buffer in controller Blocks are what are sent from a disk Device Controllers Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad8

Controller has registers which OS can write and read Write- means OS gives command to device Read- means OS learns device status…… Devices have data buffer which OS can read/write (e.g. video RAM, used to display pixels on a screen) How does CPU communicate with registers and buffers? Memory Mapped I/O Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad9

(a)Separate I/O ports and memory space. (e.g. IBM-360) (b)Memory-mapped I/O. (e.g. PDP-11) (c)Memory mapped data buffers and separate ports hybrid approach (e.g. Pentium, 0 to 64K I/O ports and 64K to1MB device data buffer) Memory-Mapped I/O Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad10

First scheme (Separate memory and I/O space) When CPU wants to read from memory or I/O port, it : Puts read on control line Puts address on address line Puts I/O space or memory space on separate 2 nd signal line to differentiate Read from memory space or I/O space It requires special I/O instructions (IN/OUT assembly language) to read and write device registers Memory mapped approach Put address on address line and let memory and I/O devices compare address with the ranges they serve and respond accordingly. How CPU addresses registers and buffers Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad11

Don’t need special instructions to read/write control registers=> can write a device driver in C Don’t need special protection to keep users from doing I/O directly. Put each device drivers on different address space, on different pages, avoid conflict. Allocate driver pages to user address space, hene: Reduce kernel size Avoid device drivers interfering with others. Avoid crash of OS due to buggy driver. Memory mapped advantages Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad12

Every instruction that can reference memory can reference control registers as well. Example: LOOP TEST PORT_4 //check if port 4 is zero BEQ READY//it is zero, go to ready BRACCH LOOP//otherwise, continue testing READY: If no memory map I/O instruction just references registers, the registers are to be loaded in CPU, then tested, need more instructions to do the test-read Slowing down the response of detecting idle devices. Memory mapped advantages contd… Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad13

Caching a device control Register: caching device status memory words, which means that old memory value (e.g. for port 4) could remain in cache, no status update, loop forever. Solution: Hardware should be able to disable caching when it is worthwhile I/O devices and memory have to respond to memory references: Works with single bus because both memory and I/O look at address on bus and decide which one to respond? Harder with multiple buses because I/O devices can’t see their addresses referred to the buses not connected with. Memory mapped disadvantage Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad14

(a) A single-bus architecture. (b) A dual-bus memory architecture. Memory-Mapped I/O Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad15

Solution-1: Try I/O devices if memory bus not respond CPU to try memory first. If it does not get a response then it tries I/O devices. Solution-2: Put Snooping device. The snoopy device pass all addresses of potent5ial interest of I/o devices. I/O devices may not be able to match the speed of memory bus. Solution-3: Filter addresses (Pentium approach) Filter addresses e.g. 640K to 1MB could be marked as non memory range forwarded to PCI bus instead of memory. Main point-have to complicate hardware to make this work Memory-Mapped I/O Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad16

CPU COULD request data one byte at a time from I/O controller. Big waste of CPU time, use DMA DMA controller on mother-board; normally one controller for multiple devices CPU reads/writes to registers in DMA controller: Memory address register Byte count register Control registers I/O port, direction of transfer, transfer units (byte/word), transfer mode, number of bytes to transfer in a burst DMA Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad17

Controller reads a block into its memory buffer Computes checksum (e.g. ECC ) Interrupts OS Now OS reads byte at a time or word at a time from controllers buffers and stores it in to the main memory When DMA is not used Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad18

Operation of a DMA transfer. How does DMA work? Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad19

Step-1:CPU programs the DMA controller registers what and where to transfer. It also instructs DC to read the data from disk into its buffer and perform checksum. Step-2: DMA controller issues a read request over a bus to disk controller. The DC reads the memory address to write, Step-3: Write to memory is another bus cycle. Step-4: After memory write, DC send ack. to DMA over the bus. DMA increment memory address and decrement word count, if count > 0 repeat step-1 to step-4. Otherwise, If byte count is zero, DMA interrupt CPU that memory transfer is complete. How does DMA work? Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad20

Cycle stealing mode-transfer goes on word at a time, competing with CPU for bus cycles. Idea is that CPU loses the occasional cycle to the DMA controller called cycle stealing. Burst mode-DMA controller grabs bus and sends a block Fly by mode-DMA controller tells device controller to send word to it instead of memory. Can be used to transfer data between devices. (e.g. memory to memory) DMA controller modes Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad21

Why buffer data in controllers? Can do check-sum Bus may be busy-need to store data someplace Is DMA really worth it? Not if : don’t have too much data to transfer. CPU is much faster than DMA controller and can do the job faster. Embedded system CPU is free; can be used for data transfer Quiz Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad22

The connections between the devices and the interrupt controller use interrupt lines on the bus rather than dedicated wires. (sets interrupt bit) PC interrupt structure Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad23

Each devise asserts a signal on a bus assigned until attended by Interrupt controller. Controller detects and distinguish the interrupt signal by the device. If no other interrupt pending it immediately process the interrupt. Otherwise process high priority interrupt, and ignores the interrupt. Controller puts number on address line telling CPU which device wants attention Table (interrupt vector) points to interrupt service routine Number on address line acts as index into interrupt vector Interrupt vector contains PC which points to start of service routine Interrupt processing Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad24

Interrupt service routine acks interrupt Saves information about interrupted program Where to save information User process stack, kernel stack are both possibilities Both have problems User process, stack pointer might me illegal may cause fatal error or stack pointer at the end of page may cause page fault, interrupt causing interrupt, difficult to handle that where to save state? Save to kernel stack, legal stack pointer, but trap to kernel space, change MMU, will invalidate TLB and cache, reloading all these is time consuming Interrupt processing Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad25

Sure, if we don’t use pipelined or superscalar CPU’s. But we do use them. Can’t assume that all instructions up to and including given instruction have been executed Pipeline-bunch of instructions are partially completed Superscalar instructions are decomposed and can execute out of order Can we save the PC and PSW? Lecture-23Ahmed Mumtaz Mustehsan, CIIT, Islamabad26