1 Comp 104: Operating Systems Concepts Devices. 2 Today Devices –Introduction –Handling I/O Device handling Buffering and caching.

Slides:



Advertisements
Similar presentations
I/O Systems & Mass-Storage Systems
Advertisements

Chapter 13: I/O Systems I/O Hardware Application I/O Interface
I/O and Networking Fred Kuhns
I/O Systems.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 13: I/O Systems I/O Hardware Application I/O Interface.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 2, 2005 Chapter 13: I/O Systems I/O Hardware.
Operating System - Overview Lecture 2. OPERATING SYSTEM STRUCTURES Main componants of an O/S Process Management Main Memory Management File Management.
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)
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.
I/O Systems CS 3100 I/O Hardware1. I/O Hardware Incredible variety of I/O devices Common concepts ◦Port ◦Bus (daisy chain or shared direct access) ◦Controller.
Device Management.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
1 Today I/O Systems Storage. 2 I/O Devices Many different kinds of I/O devices Software that controls them: device drivers.
I/O Systems CSCI 444/544 Operating Systems Fall 2008.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
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.
CHAPTER 13: I/O SYSTEMS Overview Overview I/O Hardware I/O Hardware I/O API I/O API I/O Subsystem I/O Subsystem Transforming I/O Requests to Hardware Operations.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 13+14: I/O Systems and Mass- Storage Structure I/O Hardware Application I/O.
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.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 2, 2005 Chapter 13: I/O Systems I/O Hardware.
Operating Systems CMPSC 473 I/O Management (1) November Lecture 23 Instructor: Bhuvan Urgaonkar.
Hardware Definitions –Port: Point of connection –Bus: Interface Daisy Chain (A=>B=>…=>X) Shared Direct Device Access –Controller: Device Electronics –Registers:
Silberschatz, Galvin and Gagne  Operating System Concepts I/O Hardware Incredible variety of I/O devices.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 8-2: I/O Management (Review) Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 AE4B33OSS Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O.
I/O Systems I/O Hardware Application I/O Interface
1 Module 12: I/O Systems n I/O hardware n Application I/O Interface n Kernel I/O Subsystem n Transforming I/O Requests to Hardware Operations n Performance.
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.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Principles of I/0 hardware.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 13: I/O Systems.
Cosc 4740 Chapter 12 I/O Systems. I/O Hardware Incredible variety of I/O devices –Storage –Transmission –Human-interface.
Chapter 13: I/O Systems. 13.2/34 Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware.
I/O Management Chapter 8.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 13: I/O Systems I/O Hardware Application I/O Interface.
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.
XE33OSA Chapter 13: I/O Systems. 13.2XE33OSA Silberschatz, Galvin and Gagne ©2005 Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel.
CENG334 Introduction to Operating Systems Erol Sahin Dept of Computer Eng. Middle East Technical University Ankara, TURKEY URL:
I/O Management.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 2, 2005 Chapter 13: I/O Systems I/O Hardware.
Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 13: I/O Systems.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 13: I/O Systems Overview I/O Hardware Application.
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.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 12: I/O Systems I/O hardwared Application I/O Interface Kernel I/O.
CMSC 421 Section 0202 I/O Systems Chapter 13: I/O Systems.
I/O Software CS 537 – Introduction to Operating Systems.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Chapter 13: I/O Systems.
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.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Chapter 13: I/O Systems.
CSCI 315 Operating Systems Design
I/O Systems I/O Hardware Application I/O Interface
Operating System Concepts
13: I/O Systems I/O hardwared Application I/O Interface
Selecting a Disk-Scheduling Algorithm
CS703 - Advanced Operating Systems
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Chapter 13: I/O Systems.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Chapter 13: I/O Systems.
Module 12: I/O Systems I/O hardwared Application I/O Interface
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:

1 Comp 104: Operating Systems Concepts Devices

2 Today Devices –Introduction –Handling I/O Device handling Buffering and caching

3 Operating System – An Abstract View File Manager Memory Manager Device Manager Processor Manager User Command Interface

4 Devices Peripheral devices connect to ports on the computer Data and commands to/from devices may travel along a shared set of wires called a bus (e.g. PCI bus) –Devices ignore messages not intended for them –Problem of bus contention CPUdevice BUS Memory

5 Communication Devices usually have several registers: –Status reg: indicates busy/ready etc. –Command/control reg: to pass commands to device –Data regs: to send/receive data CPU may have special I/O instructions to alter/inspect device registers Often, registers are mapped onto memory locations –e.g. writing to location 100 might send a command to a device

6 Polling vs. Interrupts OS needs to know when device ready for transfers Can poll device status –Busy-waiting may be inefficient –Occasional polling may risk losing data Alternative is interrupts –CPU interrupted when device has data or is ready to accept data e.g. Pentium –Interrupts 0-31 non-maskable for error conditions etc. –Interrupts maskable for devices

7 I/O Handling Application Kernel Device driver Device controller Device Software Hardware

8 Application I/O Interface I/O devices can be categorised by their behaviours into generic classes –Each general type is accessed through an interface, which is a standard set of functions (though the exact system calls may vary across different OS) Device driver layer hides differences among I/O controllers from kernel Devices vary on many dimensions –Character-stream vs. block –Sequential vs. random access –Sharable vs. dedicated –Speed of operation –Read-write, read only, or write only

9 Device Handling Device driver converts system calls such as open, read, write, close to low-level commands to control device Device controller converts commands to electronic signals operating the hardware Application interface –e.g. Unix: /dev directory holds special files, one per device (e.g. /dev/tty) –accessing special file activates device driver –System call ioctl() can be used to pass arbitrary commands to device driver

10 Example: Unix terminal terminal device driver process read/ write O.S. terminal output queue input queue

11 Terminal Handling Characters typed at keyboard are entered into input queue by device driver To echo, driver copies input queue to output queue Some characters require further processing by device driver –e.g. backspace remove item from input queue When read request made, pass contents of input queue to process

12 Blocking and Non-Blocking I/O Blocking: process suspended until I/O completed –Process moves from running to waiting –Easy to use and understand, but insufficient for some processes’ needs e.g. keyboard input and display on screen Non-blocking: overlap execution with I/O –Can be implemented via multi-threading: some threads block, others continue executing –Non-blocking I/O system calls: call returns quickly with value indicating number of bytes read or written Asynchronous: system call returns immediately so process runs while I/O executes –Process informed when I/O completed at some future time

13 I/O Scheduling I/O requests need to be scheduled to execute in an efficient order A good ordering can improve system performance, ensure devices are shared fairly amongst processes and reduce average I/O completion wait time Scheduling done via wait queues for each device –I/O scheduler may re-arrange the order of the queue to improve efficiency and response –Priority may be given to requests requiring a fast response –Choice of different scheduling algorithms available for disk I/O e.g. FCFS, Shortest-Seek-Time-First (SSTF), etc.

14 Buffering Consider reading a sequence of characters from a device –Making a read request for each char. is costly Instead, set up an area of memory called a buffer –read a block of chars into buffer in one operation –subsequent chars taken directly from buffer –only need to access device when buffer empties Similarly for writing –place each char in a buffer –send to device only when buffer full

15 Buffering Double buffering –read/write one buffer while other being filled/emptied Buffering may be done by –software, e.g. operating system or library routines –hardware, e.g. disk drive Direct Memory Access (DMA) –fast devices (e.g. disk) may write directly into memory buffer, interrupting CPU only when finished –CPU might be delayed while DMA controller accesses memory (cycle stealing) Buffer writes can cause inconsistency problems –may need to flush buffers periodically (e.g. Unix sync operation every 30 secs)

16 Caching Similar to buffering, but idea is to speed up access to frequently used items by keeping copies in a faster medium (the cache) Other differences: Buffer Cache Items viewed as data in transit Items viewed as copies of the original FIFO Random access Once item read, viewed as Items may be read many times deleted

Question To assist in locating a bug that is causing a program to crash, a programmer inserts print statements as follows: begin... print(“Got to point A without crashing”);... print(“Got to B without crashing”);... end a)Too much information will probably be written to the screen to allow location of the bug. b)The very insertion of the print statements will probably alter the program’s behaviour, preventing the bug from occurring. c)The new diagnostic statements will interfere with the program’s existing output, introducing further bugs. d)The bug will probably make all print statements inoperable. e)The use of output buffers by the system might prevent some messages from being written. 17 Answer: e The buffers may not be flushed, and the program may continue (and crash) giving misleading information.

18

19 Spooling Some devices non-sharable –e.g. printer: multiple processes cannot write to it simultaneously Solution is a daemon process called a spooler –SPOOL: Simultaneous Peripheral Operations On- Line Processes send their printer output via spooler daemon Spooler creates a temp file for each process, and writes output to those files When process completes, spooler adds file to a queue for printing (de-spooling)

20 Performance I/O is a major factor in system performance: heavy demands are placed on the CPU –Device driver code must be executed and processes scheduled efficiently as they block and unblock –Involves large amount of context switching –Network traffic adds to this Measures can be taken to improve performance that include: –Reducing the number of context switches –Reduce interrupt frequency by using large transfers and polling –Making use of DMA...

21 End of Section Files and I/O –Files and directory structure –Filestore allocation policies –Device handling –Buffering and caching The next section of the module will be Compilers