Comp 204: Computer Systems and Their Implementation. Lecture 18: Devices

Similar documents
Devices. Today. Comp 104: Operating Systems Concepts. Operating System An Abstract View 05/01/2017. Devices. Devices

Device-Functionality Progression

Chapter 12: I/O Systems. I/O Hardware

Input/Output Systems

Module 12: I/O Systems

Module 12: I/O Systems

I/O Systems. 04/16/2007 CSCI 315 Operating Systems Design 1

Chapter 13: I/O Systems

by I.-C. Lin, Dept. CS, NCTU. Textbook: Operating System Concepts 8ed CHAPTER 13: I/O SYSTEMS

Chapter 13: I/O Systems

Chapter 13: I/O Systems. Chapter 13: I/O Systems. Objectives. I/O Hardware. A Typical PC Bus Structure. Device I/O Port Locations on PCs (partial)

Chapter 13: I/O Systems

Chapter 12: I/O Systems

Chapter 13: I/O Systems

Chapter 12: I/O Systems. Operating System Concepts Essentials 8 th Edition

Lecture 13 Input/Output (I/O) Systems (chapter 13)

Operating System: Chap13 I/O Systems. National Tsing-Hua University 2016, Fall Semester

Chapter 13: I/O Systems. Operating System Concepts 9 th Edition

Chapter 13: I/O Systems

I/O Systems. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

I/O Systems. Jo, Heeseung

Today: I/O Systems. Architecture of I/O Systems

I/O Handling. ECE 650 Systems Programming & Engineering Duke University, Spring Based on Operating Systems Concepts, Silberschatz Chapter 13

Chapter 13: I/O Systems

CS330: Operating System and Lab. (Spring 2006) I/O Systems

The control of I/O devices is a major concern for OS designers

I/O Systems. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

Chapter 13: I/O Systems

Chapter 13: I/O Systems

Module 11: I/O Systems

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

Chapter 13: I/O Systems

CS370 Operating Systems

Silberschatz and Galvin Chapter 12

CSE 4/521 Introduction to Operating Systems. Lecture 24 I/O Systems (Overview, Application I/O Interface, Kernel I/O Subsystem) Summer 2018

Lecture 15: I/O Devices & Drivers

Input-Output (I/O) Input - Output. I/O Devices. I/O Devices. I/O Devices. I/O Devices. operating system must control all I/O devices.

Ref: Chap 12. Secondary Storage and I/O Systems. Applied Operating System Concepts 12.1

CSE 451: Operating Systems Winter I/O System. Gary Kimura

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

CS370 Operating Systems

Operating Systems. V. Input / Output

操作系统概念 13. I/O Systems

Input/Output Systems

CS 134. Operating Systems. April 8, 2013 Lecture 20. Input/Output. Instructor: Neil Rhodes. Monday, April 7, 14

[08] IO SUBSYSTEM 1. 1

COT 4600 Operating Systems Fall Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM

Input Output (IO) Management

I/O SYSTEMS. Sunu Wibirama

NWI-IBC019: Operating systems

I/O Management and Disk Scheduling. Chapter 11

Chapter 5 Input/Output. I/O Devices

Operating Systems 2010/2011

I/O. CS 416: Operating Systems Design Department of Computer Science Rutgers University

Answer to exercises chap 13.2

Outline. Operating Systems: Devices and I/O p. 1/18

OPERATING SYSTEMS CS136

CSE 120. Overview. July 27, Day 8 Input/Output. Instructor: Neil Rhodes. Hardware. Hardware. Hardware

Chapter-6. SUBJECT:- Operating System TOPICS:- I/O Management. Created by : - Sanjay Patel

CIS Operating Systems I/O Systems & Secondary Storage. Professor Qiang Zeng Spring 2018

Introduction. CS3026 Operating Systems Lecture 01

CSCI-GA Operating Systems I/O. Hubertus Franke

CS420: Operating Systems. Kernel I/O Subsystem

Input/Output Problems. External Devices. Input/Output Module. I/O Steps. I/O Module Function Computer Architecture

CHAPTER 12 AND 13 - MASS-STORAGE STRUCTURE & I/O- SYSTEMS

Operating System Design Issues. I/O Management

I/O. Fall Tore Larsen. Including slides from Pål Halvorsen, Tore Larsen, Kai Li, and Andrew S. Tanenbaum)

I/O. Fall Tore Larsen. Including slides from Pål Halvorsen, Tore Larsen, Kai Li, and Andrew S. Tanenbaum)

The Device Driver Interface. Input/Output Devices. System Call Interface. Device Management Organization

CSE 4/521 Introduction to Operating Systems. Lecture 27 (Final Exam Review) Summer 2018

Input/Output Management

19: I/O. Mark Handley. Direct Memory Access (DMA)

I/O & Storage. Jin-Soo Kim ( Computer Systems Laboratory Sungkyunkwan University

UC Santa Barbara. Operating Systems. Christopher Kruegel Department of Computer Science UC Santa Barbara

Input / Output. School of Computer Science G51CSA

Input/Output. Chapter 5: I/O Systems. How fast is I/O hardware? Device controllers. Memory-mapped I/O. How is memory-mapped I/O done?

-Device. -Physical or virtual thing that does something -Software + hardware to operate a device (Controller runs port, Bus, device)

Input/Output. Today. Next. Principles of I/O hardware & software I/O software layers Disks. Protection & Security

CIS Operating Systems I/O Systems & Secondary Storage. Professor Qiang Zeng Fall 2017

Organisasi Sistem Komputer

Generic Model of I/O Module Interface to CPU and Memory Interface to one or more peripherals

Computer Organization ECE514. Chapter 5 Input/Output (9hrs)

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

CSI3131 Final Exam Review

Computer System Overview OPERATING SYSTEM TOP-LEVEL COMPONENTS. Simplified view: Operating Systems. Slide 1. Slide /S2. Slide 2.

File. File System Implementation. File Metadata. File System Implementation. Direct Memory Access Cont. Hardware background: Direct Memory Access

Operating Systems CMPSC 473. Input/Output April 22, Lecture 22 Instructor: Trent Jaeger

5.b Principles of I/O Hardware CPU-I/O communication

Operating Systems (CS1022) Input/Output. Yagiz Özbek Evren

Slide 5-1. Device. Management. Operating Systems: A Modern Perspective, Chapter 5. Copyright 2004 Pearson Education, Inc.

Operating Systems. Steven Hand. Michaelmas / Lent Term 2008/ lectures for CST IA. Handout 4. Operating Systems

CSC Operating Systems Spring Lecture - XIX Storage and I/O - II. Tevfik Koşar. Louisiana State University.

RAID Structure. RAID Levels. RAID (cont) RAID (0 + 1) and (1 + 0) Tevfik Koşar. Hierarchical Storage Management (HSM)

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

C02: Interrupts and I/O

Chapter 11 I/O Management and Disk Scheduling

Operating Systems. V. Input / Output. Eurecom

CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University

What Operating Systems Do An operating system is a program hardware that manages the computer provides a basis for application programs acts as an int

CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University

Transcription:

Comp 204: Computer Systems and Their Implementation Lecture 18: Devices 1

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

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

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 Memory CPU device device device BUS 4

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 5

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 32-255 maskable for devices 6

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

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 8

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 9

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

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 11

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 12

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. 13

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 14

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) 15

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 16

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. Answer: e The buffers may not be flushed, and the program may continue (and crash) giving misleading information. 17

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) 18

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... 19

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 20