CS 149: Operating Systems April 14 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak www.cs.sjsu.edu/~mak.

Slides:



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

Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Categories of I/O Devices
I/O Systems.
Avishai Wool lecture Introduction to Systems Programming Lecture 8 Input-Output.
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.
File System Implementation
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.
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.
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
Copyright ©: Nahrstedt, Angrave, Abdelzaher
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
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.
Segmentation & O/S Input/Output Chapter 4 & 5 Tuesday, April 3, 2007.
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 Lecture 20: I/O n I/O hardware n I/O structure n communication with controllers n device interrupts n device drivers n streams.
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 13: I/O Systems.
I/O management is a major component of operating system design and operation Important aspect of computer operation I/O devices vary greatly Various methods.
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 12: File System Implementation File System Structure File System Implementation.
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,
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:
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.
1 Chapter 13 Input/Output (I/O) Systems Dr. İbrahim Körpeoğlu Bilkent University Department of Computer Engineering.
Computer Studies (AL) I/O Management. Reference Silberschatz, Galvin, Gagne “Operating System Concepts 6 th edition”, 2003, Wiley Stallings, “Operating.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 13: I/O Systems Overview I/O Hardware Application.
CS 149: Operating Systems March 5 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
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.
Module 11: I/O Systems Reading: Chapter 13 Objectives  Explore the structure of the operating system’s I/O subsystem.  Discuss the principles of I/O.
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.
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 I/O Hardware Application I/O Interface
Chapter 13: I/O Systems.
Module 12: I/O Systems I/O hardwared Application I/O Interface
Presentation transcript:

CS 149: Operating Systems April 14 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 2 Journaling File Systems  Journaling file systems record each update to the file system as a transaction. Becoming common on many operating systems.  All transactions are written sequentially to a log.  A transaction is considered committed once it is written to the log file.  The user process can continue execution.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 3 Journaling File Systems, cont’d  The transactions in the log are asynchronously replayed to the file system structures. When the file system structures are modified, the transaction is removed from the log.  If the file system crashes, all remaining transactions in the log must still be performed.  Faster recovery from a crash. Removes the chance of inconsistency of metadata.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 4 Virtual File System (VFS)  A UNIX Virtual File System (VFS) provides an object-oriented way to implement file systems.  VFS allows the same system call interface (the API) to be used for different types of file systems.  Separate file-system generic operations from implementation details.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 5 Virtual File System (VFS), cont’d  The implementation can be one of many file systems types, or a network file system.  Implement vnodes which hold inodes or network file details.  The API is to the VFS interface, rather than any specific type of file system.  Dispatch an operation to the appropriate file system implementation routines.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 6 Virtual File System (VFS) Schematic view of a virtual file system. Operating Systems Concepts, 9 th edition Silberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 7 Network File System (NFS)  Commonplace implementation of a client-server file system.  Access remote files across local-area networks (LANs) or wide-area networks (WANs). Use the TCP or UDP/IP protocol.  Operate in a heterogeneous environment of different machines, operating systems, and network architectures.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 8 Network File System (NFS), cont’d  Provide file sharing across a set of independent machines and independent file systems.  Mount a remote file system onto a local mount point. Transparent sharing.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 9 NFS Mounting (a) A local file system U and two remote file systems S1 and S2. (b) The result of mounting the remote /usr/shared from S1 onto /usr/local (a)(b) Operating Systems Concepts, 9 th edition Silberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 10 Network File System (NFS) Schematic view of the NFS architecture. Operating Systems Concepts, 9 th edition Silberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 11 Assignment #6: UNIX I/O  The purpose of this assignment is to practice making UNIX I/O system calls in C.  In a multiplexed manner, your main process will read from multiple files, and read from the standard input (the terminal).  Create five pipes and spawn five child processes. Connect a pipe to each child process. Each child process should write to its pipe. The parent process should read from all the pipes.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 12 Assignment #6, cont’d  Each of the first four child processes should generate time stamped messages to the nearest 1000 th of a second (time starts at 0): 0:00.123: Child 1 message 1 0:02.456: Child 1 message 2 etc. and write the messages one at a time to its pipe. Sleep for a random time of 0, 1, or 2 seconds between messages. Terminate the process after 30 seconds.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 13 Assignment #6, cont’d  Meanwhile, the fifth child process should repeatedly prompt at the terminal (standard out) and read one line of input (standard in) typed by the user. Write the message (with time stamp) to its pipe. Immediately prompt for the next message. Terminate the process after 30 seconds.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 14 Assignment #6, cont’d  After spawning the child processes, the parent process should repeatedly read lines from the pipes.  Use the select() system call to determine whether any of the pipes has any input. Read the “man” pages about select().

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 15 Assignment #6, cont’d  Write the lines to an output file output.txt in the order that they were read.  Prepend each line with a time stamp to the nearest 1000 th of a second. Therefore, each line with have two time stamps. The first time stamp from the parent process. Followed by the child process’s time stamp.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 16 Assignment #6, cont’d  File output.txt will contain a mixture of lines from the child processes.  Terminate the main process after all the child processes have terminated.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 17 Assignment #6, cont’d  a zip file to Your C source files Your output.txt file A brief report describing any issues you encountered.  Name the zip file after your team. Example: SuperCoders.zip  Subject line: CS 149- section number Assignment #6 team name  Due: Monday, April 27 at 11:59 PM

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 18 Types of I/O Devices  Block Store data in fixed-sized blocks. Each block has a separate address.  Common block sizes are 512 bytes to 32K bytes. Each block can be read or written independently. Example system calls: read(), write(), seek(). Example?  disk drive

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 19 Types of I/O Devices, cont’d  Character Accept a stream of characters.  No block structure. Example system calls: get(), put()  Higher-level routines implement line-oriented I/O. Example?  keyboards, printers, mice, etc.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 20 Types of I/O Devices, cont’d  Sequential access Transfer data from storage in a fixed order as determined by the device. Example?  tape drive, serial and parallel ports  Random access Seek to any storage address to read or write data. Example?  disk drive

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 21 Types of I/O Devices, cont’d  Shared Multiple processes can use the device concurrently. Example?  disk drive  Dedicated Only one process at a time can use the device. Example?  keyboard, mouse, tape drive

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 22 Types of I/O Devices, cont’d  Read only Processes can only read from the device. Example?  scanner  Write only Processes can only write to the device. Example?  printer

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 23 Types of I/O Devices, cont’d  Read-write Processes can both read from and write to the device. Examples?  disk drive, tape drive

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 24 Types of I/O Devices, cont’d Operating Systems Concepts, 9 th edition Silberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 25 Hardware to Support I/O  Port A connection point in the machine where a device or device cable plugs in. Usually uses an industry-standard communications protocol. Examples: serial port, parallel port, VGA port  Bus A set of wires shared by multiple different devices. Uses a rigidly defined protocol.  An expansion bus handles slow devices. Example: PCI, SCSI

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 26 Typical Computer Bus Architecture Operating Systems Concepts, 9 th edition Silberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 27 Device Controllers  A separate hardware unit that interfaces with an I/O device. A more modular and general machine design. AKA device adapter  Typically a separate printed circuit card plugged into the system mother board. A cable leads from the card to the device. One controller can handle multiple identical devices.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 28 Device Controllers, cont’d  Often uses an industry standard interface. ANSI, IEEE, or ISO standard. Example: Disk controllers use the IDE (Integrated Drive Electronics) or SCSI (Small Computer System Interface) standards.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 29 Device Controllers, cont’d  Device controllers typically have built-in control registers and data buffers to use during I/O operations. Each control register has a port number. Special I/O instructions can read from such a port: or write to such a port: IN REG,PORT OUT PORT,REG

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 30 Device Controllers, cont’d Modern Operating Systems, 3 rd ed. Andrew Tanenbaum (c) 2008 Prentice-Hall, Inc All rights reserved

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 31 Memory-Mapped I/O  A device controller’s I/O registers can be part of the address space for main memory. Each register is assigned a unique memory address. Such addresses are not used by normal memory operations.  Whenever a process wants to read from memory, it puts the memory address out onto the system bus. If the address is that of an I/O register, the corresponding device goes to get the data. Otherwise, it’s a normal read from main memory.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 32 Memory-Mapped I/O, cont’d  A hybrid scheme Memory-mapped data buffers. Separate I/O ports for control registers. Example: Intel Pentium

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 33 Memory-Mapped I/O (a) Separate I/O and memory space. (b) Memory-mapped I/O. (c) Hybrid. Modern Operating Systems, 3 rd ed. Andrew Tanenbaum (c) 2008 Prentice-Hall, Inc All rights reserved

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 34 Direct Memory Access (DMA)  Requires a DMA controller.  The DMA controller can be used by multiple I/O devices. Regulates concurrent data transfers.  The controller accesses the system bus independently of the CPU.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 35 Direct Memory Access (DMA), cont’d  The CPU can access the controller’s registers. memory address register byte count register control registers  The DMA controller handles I/O upon instruction from the CPU. Works in parallel with the CPU.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 36 DMA Example: Data Read Operating Systems Concepts, 9 th edition Silberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 37 I/O Software Layers  Layers of the I/O software system: Modern Operating Systems, 3 rd ed. Andrew Tanenbaum (c) 2008 Prentice-Hall, Inc All rights reserved

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 38 Device Drivers  Device drivers are lower-level system software. File systems deal with abstract block devices.  Provide uniform device access by the OS kernel to the I/O subsystem. New devices are being invented all the time. No hope of using the these devices without standard device driver interfaces. Analogous to the OS system calls which provide a standard interface between applications and the OS.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 39 Device Drivers Without a standard driver interface. With a standard driver interface. Modern Operating Systems, 3 rd ed. Andrew Tanenbaum (c) 2008 Prentice-Hall, Inc All rights reserved

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 40 Device-Independent Software  Most I/O software is device-independent. The remaining is device-specific.  Perform I/O operations that are common to all devices.  Provide a uniform interface to user-level applications software.  Operations that can be done in the device-independent layer may actually be done instead by a device driver. More efficient, perhaps?

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 41 Device-Independent Software, cont’d Functions of the device-independent I/O software.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 42 I/O Interrupts  An I/O device triggers the CPU’s interrupt-request line. An interrupt handler receives interrupts. Some interrupts can are maskable to ignore or delay the interrupts. Other interrupts are nonmaskable.  An interrupt vector dispatches the interrupt to the correct interrupt handler. Based on priority.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 43 I/O Interrupts Operating Systems Concepts, 9 th edition Silberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 44 Synchronous I/O Operations  Synchronous (AKA blocking)  Perform I/O synchronized with the process. The process waits for the I/O operation to complete.  Predictable response times.  Insufficient for some needs.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 45 Asynchronous I/O Operations  Asynchronous (AKA nonblocking)  Requires multithreading.  Perform I/O not synchronized with the process. After initiating an I/O operation, a process continues without waiting for completion. The process receives an interrupt at an unpredictable time when the I/O operation completes. Irregular or unpredictable response times.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 46 Types of I/O Operations SynchronousAsynchronous Operating Systems Concepts, 9 th edition Silberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 47 Kernel I/O Subsystem  Scheduling Some I/O request ordering via per-device queues. The OS attempts fairness.  Buffering Store data in memory while transferring between devices. Cope with device speed mismatch. Cope with device transfer size mismatch.

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 48 Kernel I/O Subsystem, cont’d  Caching Fast memory holding copy of data. Always just a copy. Key to performance.  Spooling Hold output for a device if the device can serve only one request at a time. Example: printing

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 49 Kernel I/O Subsystem, cont’d  Device reservation Provide exclusive access to a device. System calls for allocation and deallocation. Watch out for deadlocks!

Computer Science Dept. Spring 2015: April 14 CS 149: Operating Systems © R. Mak 50 Kernel I/O Subsystem Operating Systems Concepts, 9 th edition Silberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved