I/O Software CS 537 – Introduction to Operating Systems.

Slides:



Advertisements
Similar presentations
Categories of I/O Devices
Advertisements

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.
04/14/2008CSCI 315 Operating Systems Design1 I/O Systems Notice: The slides for this lecture have been largely based on those accompanying the textbook.
OPERATING SYSTEM LESSON 2. INTRODUCTION TO OPERATING SYSTEM Computer Hardware’s complexity Operating Systems (OS) hide this complexity from users OS manages.
Operating Systems Input/Output Devices (Ch , 12.7; , 13.7)
Operating System - Overview Lecture 2. OPERATING SYSTEM STRUCTURES Main componants of an O/S Process Management Main Memory Management File Management.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
I/O Hardware n Incredible variety of I/O devices n Common concepts: – Port – connection point to the computer – Bus (daisy chain or shared direct access)
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
OS Spring’03 Introduction Operating Systems Spring 2003.
1 I/O Devices Controller: physically controls the devices Devices are diverse and complicated Present simpler interface to OS E.g, convert a linear sector.
Memory Management, File Systems, I/O How Multiprogramming Issues Mesh ECEN 5043 Software Engineering of Multiprogram Systems University of Colorado, Boulder.
1 Device Management The von Neumann Architecture System Architecture Device Management Polling Interrupts DMA operating systems.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Input/Output – 3 I/O Software CS 342 – Operating Systems Ibrahim Korpeoglu.
1 I/O Management in Representative Operating Systems.
Operating Systems Input/Output Devices (Ch 5: )
Copyright ©: Nahrstedt, Angrave, Abdelzaher
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
I/O Systems ◦ Operating Systems ◦ CS550. Note:  Based on Operating Systems Concepts by Silberschatz, Galvin, and Gagne  Strongly recommended to read.
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 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
Chapter 1. Introduction What is an Operating System? Mainframe Systems
Cpr E 308 Input/Output Recall: OS must abstract out all the details of specific I/O devices Today –Block and Character Devices –Hardware Issues – Programmed.
Segmentation & O/S Input/Output Chapter 4 & 5 Tuesday, April 3, 2007.
CSC 322 Operating Systems Concepts Lecture - 25: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Hardware Definitions –Port: Point of connection –Bus: Interface Daisy Chain (A=>B=>…=>X) Shared Direct Device Access –Controller: Device Electronics –Registers:
I/O Systems I/O Hardware Application I/O Interface
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS6: Device Management 6.1. Principles of I/O.
CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.
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.
1 Comp 104: Operating Systems Concepts Devices. 2 Today Devices –Introduction –Handling I/O Device handling Buffering and caching.
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.
Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 1: Introduction What Operating Systems Do Computer-System.
Background: Operating Systems Brad Karp UCL Computer Science CS GZ03 / M th November, 2008.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
Chapter 13 – I/O Systems (Pgs ). Devices  Two conflicting properties A. Growing uniformity in interfaces (both h/w and s/w): e.g., USB, TWAIN.
Silberschatz, Galvin and Gagne  Operating System Concepts Six Step Process to Perform DMA Transfer.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 13: I/O 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.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Input/Output – 2 I/O Software CS 342 – Operating Systems Ibrahim Korpeoglu.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 12: I/O Systems I/O hardwared Application I/O Interface Kernel 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.
1 Chapter 11 I/O Management and Disk Scheduling Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and.
OPERATING SYSTEMS STRUCTURES Jerry Breecher 2: Operating System Structures 1.
Introduction to Operating Systems Concepts
Computer System Structures
Input/Output (I/O) Important OS function – control I/O
Module 12: I/O Systems I/O hardware Application I/O Interface
Chapter 13: I/O Systems Modified by Dr. Neerja Mhaskar for CS 3SH3.
CS 286 Computer Organization and Architecture
Module 2: Computer-System Structures
I/O Systems I/O Hardware Application I/O Interface
Operating Systems Chapter 5: Input/Output Management
Operating System Concepts
13: I/O Systems I/O hardwared Application I/O Interface
CS703 - Advanced Operating Systems
Chapter 5: I/O Systems.
Module 2: Computer-System Structures
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Module 2: Computer-System Structures
Module 2: Computer-System Structures
Module 12: I/O Systems I/O hardwared Application I/O Interface
Presentation transcript:

I/O Software CS 537 – Introduction to Operating Systems

Programmed I/O Basic idea: –CPU does all communication directly with device –CPU waits for device to complete one operation before issuing another request Flow of events –user program issues a request for I/O –OS copies a single byte (word) to/from device –OS waits for device to become ready again –OS then copies the next byte (word) to/from device –repeat this process until all the data copied –return control to the user

Programmed I/O psuedo-code for reading from device for(i=0; i<count; i++) { while(device_status_register != READY); device_data_register = buffer[i]; } return_to_user();

Programmed I/O Advantages: –simple to implement –very little hardware support Disadvantages: –busy waiting (polling) ties up CPU for long periods with no useful work (maybe)

Inerrupt Driven I/O Basic idea: –similar to programmed I/O but instead of busy waiting, block the process and have the I/O device interrupt when it is ready Flow of events: –user program issues a request for I/O –OS copies a single byte (word) to/from device –OS schedules another process –device interrupts the CPU –OS then copies the next byte (word) to/from device and reschedules again –repeat this process until all the data copied –return control to the user

Interrupt Driven I/O psuedo-code for reading from device –code executed on system call block_user(); count = n;i = 0; while(device_status_register != READY); device_data_register = buffer[i]; schedule(); –code executed on interrupt from device if(count == 0) { unblock_user(); } else { device_data_register = buffer[i]; count--;i++; } return_from_interrupt();

Interrupt Driven I/O Advantages: –system can do useful work while device not ready Disadvantage –lots of interrupts interrupts are expensive to do have to run interrupt code fragment on everyone what if the device is not slow?

DMA Basic idea: –exactly like programmed I/O but instead of the device communicating with CPU, it communicates with DMA controller Flow of events: –user program issues a request for I/O –OS blocks calling process –OS programs DMA controller –OS schedules another process –DMA controller then does programmed I/O with busy waits and all it may actually be able to handle more than one device at a time –DMA interrupts CPU when data transfer complete –OS unblocks user process

DMA psuedo-code for reading from device –code executed on system call block_user(); set_up_DMAC(); scheduler(); –code executed on interrupt from device unblock_user(); return_from_interrupt();

DMA Advantages –only one interrupt to the CPU for a single I/O operation CPU only bothered when I/O finished Disadvantages –Memory conflicts between CPU and DMAC –DMAC is much slower than CPU what if device is very fast? what if there is no other work for CPU?

I/O Software Layers Modern I/O software is broken into layers –a common interface from one layer to the next allows for high degree of flexibility abstraction –you don’t need to know how each layer works – you just need to know how to interact with it hardware device drivers device-independent OS software user-level I/O software interrupts

User Level Software library calls –users generally make library calls that then make the system calls –example: int count = write(fd, buffer, n); write function is run at the user level simply takes parameters and makes a system call –another example: printf(“My age: %d\n”, age); takes a string, reformats it, and then calls the write system call

User Level Software Spooling –user program places data in a special directory –a daemon (background program) takes data from directory and outputs it to a device the user doesn’t have permission to directly access the device daemon runs as a privileged user –prevents users from tying up resources for extended periods of time printer example –OS never has to get involved in working with the I/O device

Device Independent OS Software Make devices look like files –this is the Unix and Windows approach You can open, read, write, close, etc. a device –some devices may be read only (keyboard) –others may be write only (monitor) Example – writing to a disk fd = open(“/dev/hda1”, O_RDONLY); lseek(fd, 1024, SEEK_SET); write(fd, buffer, size); close(fd);

Device Independent OS Software OS knows the file represents a device because the meta data says so –in Unix, there is no file – just an inode How does OS know what to do on a read? –meta data includes a major and a minor number major: what category of device it is minor: what specific device in the category Protection of devices is now simple –put the access rights for the device in the meta data How to deal with errors? –let the lower level, device specific software deal with it –return standard error codes to indicate a failure

Device Independent OS Software Many devices require buffering –want to make this interface common for all devices as well Where to buffer the data? –usually, not in user space page might get swapped out –usually place buffered data in the kernel space locked in memory –double buffering while copying data to/from user space, more data may arrive keep a second buffer for new data while the other is being transferred switch back and forth between the two buffers

Device Independent OS Software Advantages of buffering –increases efficiency can transfer entire blocks instead of single words –allows for asynchronous operation user transfers data to the kernel and moves on Disadvantages of buffering –lots of copying can reduce performance

Device Independent OS Software user space kernel space network controller buffer network Data gets copied 5 times! WHY?

Drivers At some level we must deal with the fact that I/O devices are different Drivers are the level of software that do this –usually provided by the device vendor A single driver handles a single device –or maybe a class of devices imagine IDE disks of different sizes and speeds –use the major number to indicate which driver to run –the minor number is passed as a parameter to the driver which specific device of a particular class

Drivers Basic driver functions –accept read/write commands from the device independent layer and translate into actual commands for the device must write/read the various I/O ports of the device –translate input parameters and check for errors –handle device errors if possible maybe retry a read request if checksum fails

Drivers In today’s world, drivers are built into the operating system Better solution would be to put them in I/O space and provide system calls for I/O port interaction –kernel wouldn’t crash because of a buggy driver Drivers are often implemented as separate processes –allows them to block and let the OS reschedule –makes interface between drivers and OS much simpler Devices are constantly added and removed –must allow drivers to be dynamically plugged into the system