1 I/O and Filesystems. 2 How to provide interfaces Rough reading guide (no exam guarantee): Tanenbaum Ch. 5.1 – 5.5 & 6.1-3 Silberschatz Ch. 13 & 10.1-4,

Slides:



Advertisements
Similar presentations
Chapter 5 Input/Output 5.1 Principles of I/O hardware
Advertisements

Matakuliah: sistem Operasi 1. Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : menjelaskan konsep sistem file (C2) 2.
Avishai Wool lecture Introduction to Systems Programming Lecture 8 Input-Output.
Part 5 (Stallings) Input/Output 5.1 Principles of I/O hardware
1 Input/Output Chapter Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks 5.5 Clocks 5.6 Character-oriented.
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.
Operating Systems Input/Output Devices (Ch , 12.7; , 13.7)
1 Pertemuan 21 Sistem File Matakuliah: T0316/sistem Operasi Tahun: 2005 Versi/Revisi: 5.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
File Systems Topics –File –Directory –File System Implementation Reference: Chapter 5: File Systems Operating Systems Design and Implementation (Second.
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.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
Why Do We Need Files? Must store large amounts of data. Information stored must survive the termination of the process using it - that is, be persistent.
Chapter 5 Input/Output 5.1 Principles of I/O hardware
Input/Output The messiest part of O.S.
1 Device Management The von Neumann Architecture System Architecture Device Management Polling Interrupts DMA operating systems.
1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a nightmare.” - Japanese Proverb.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Input/Output – 3 I/O Software CS 342 – Operating Systems Ibrahim Korpeoglu.
1/21/2010CSCI 315 Operating Systems Design1 Computer System Structures Notice: The slides for this lecture have been largely based on those accompanying.
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.
Chapter 4 File Systems Files Directories Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
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
1 Input/Output. 2 Principles of I/O Hardware Some typical device, network, and data base rates.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file 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.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 8-1: I/O Management Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Segmentation & O/S Input/Output Chapter 4 & 5 Tuesday, April 3, 2007.
Sistem Operasi IKH311 Masukan Luaran (Input/Output)
CSC 322 Operating Systems Concepts Lecture - 25: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
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 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.
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.
File Systems Long-term Information Storage Store large amounts of information Information must survive the termination of the process using it Multiple.
1 Chapter 2: Computer-System Structures  Computer System Operation  I/O Structure  Storage Structure  Storage Hierarchy  Hardware Protection  General.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
File Systems (1). Readings r Reading: Disks, disk scheduling (3.7 of textbook; “How Stuff Works”) r Reading: File System Implementation ( of textbook)
Operating Systems COMP 4850/CISG 5550 File Systems Files Dr. James Money.
CS450/550 FileSystems.1 Adapted from MOS2E UC. Colorado Springs CS450/550 Operating Systems Lecture 6 File Systems Palden Lama Department of Computer.
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,
Why Do We Need Files? Must store large amounts of data. Information stored must survive the termination of the process using it - that is, be persistent.
Chapter 5 Input/Output 5.1 Principles of I/O hardware
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.
Annotated by B. Hirsbrunner File Systems Chapter Files 5.2 Directories 5.3 File System Implementation 5.4 Security 5.5 Protection Mechanism 5.6 Overview.
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.
Chapter 6 File Systems. Essential requirements 1. Store very large amount of information 2. Must survive the termination of processes persistent 3. Concurrent.
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 Chapter 5 Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
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.
F ILE M ANAGEMENT Prepared By: Dr. Vipul Vekariya.
File System Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki CS 314.
1 Chapter 11 I/O Management and Disk Scheduling Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and.
Introduction to Operating Systems Concepts
I/O Management.
CS703 - Advanced Operating Systems
CPSC 457 Operating Systems
Operating Systems Chapter 5: Input/Output Management
CS703 - Advanced Operating Systems
Chapter 5: I/O Systems.
Department of Computer Science
Chapter 5 File Systems -Compiled for MCA, PU
Presentation transcript:

1 I/O and Filesystems

2 How to provide interfaces Rough reading guide (no exam guarantee): Tanenbaum Ch. 5.1 – 5.5 & Silberschatz Ch. 13 & , Also: Patterson Ch. 8 (I/O)

3 I/O A computer without peripheral devices is pretty much useless Old mainframes required kernel-recompile to install new devices Now: PCs have millions of possible devices

4 Goals for I/O Handling Enable use of peripheral devices Present a uniform interface for –Users (files etc.) –Devices drivers Hide the details of devices from users (and OS)

5 Device Controllers I/O devices have components: –mechanical component –electronic component The electronic component is the device controller –may be able to handle multiple devices –OS deals with controllers not devices Controller's tasks –convert bit stream to block of bytes –perform error correction as necessary –make blocks available to main memory

6 Relevant Device Properties (1) The mechanical/electronic properties of devices impact software –timing (seek times etc.) –interrupts –data rates

7 Relevant Device Properties (2) Some typical device, network, and bus data rates

8 Accessing Devices (1) Most devices provide –buffers (in / out) –control registers –status registers These are accessed from the OS/Apps –I/O ports –memory-mapped –hybrid

9 Accessing Devices (2) a)Separate I/O and memory space b)Memory-mapped I/O c)Hybrid

10 Memory-Mapped I/O +No special instruction in assembler needed +No special protection needed (remember VM) +Testing control registers directly Not load and test! -Caching of control registers? -One bus?

11 Memory-Mapped I/O (a) A single-bus architecture (b) A dual-bus memory architecture

12 Memory-Mapped I/O

13 Shuffling Data Data needs to be sent –one byte at a time –several bytes at a time Using the CPU to shuffle small amounts of data may be inefficient  Direct Memory Access (DMA)

14 Direct Memory Access (DMA) Operation of a DMA transfer

15 Interrupts Revisited Connections between devices and interrupt controller actually use interrupt lines on the bus rather than dedicated wires

16 Goals of I/O Software (1) Device independence –programs can access any I/O device –without specifying device in advance (file on floppy, hard drive, or CD-ROM) Uniform naming –name a file or device as a string or an integer –not depending on which machine Error handling –handle as close to the HW as possible

17 Goals of I/O Software (2) Synchronous vs. asynchronous transfers –blocking transfers vs. interrupt-driven –OS may make interrupt-driven operations look like blocking to the user Buffering –data coming off a device cannot be stored in final destination –OS should buffer for pre-processing/RT.. Sharable vs. dedicated devices –disks are sharable –tape drives would not be –OS should be able to support both

18 I/O There are three kinds of I/O handling Programmed I/O –“Do it all yourself” Interrupt-driven I/O –“Here you are, now tell me when its done” DMA-based I/O –“Let someone else do it”

19 Programmed I/O

20 Interrupt-Driven I/O Writing a string to the printer using interrupt-driven I/O Code for system callCode for interrupt handler

21 I/O Using DMA Printing a string using DMA a) code executed when the print system call is made b) interrupt service procedure

22 I/O Software Layers Layers of the I/O Software System

23 Interrupt Handlers (1) Interrupt handlers are best hidden –have driver starting an I/O operation block until interrupt notifies of completion Interrupt procedure does its task –then unblocks driver that started it

24 Interrupt Service Routine Steps that must be performed in software when interrupt occurs (no complete list) Step 1: Preparation 1.Save regs not already saved by interrupt hardware 2.Set up context for interrupt service procedure 3.Ack interrupt controller, reenable interrupts () Step 2: Actual task execution 1.Copy registers from where saved 2.Run service procedure 3.Schedule and run a new process (+ new context)

25 Interrupt Handlers (3) Interrupt handlers should be fast (why?) Sometimes there is a lot of things to do –Copying buffers, waking up processes, starting new I/O ops, etc. Solution: split in two parts –Top half: disabled interrupts, only essential work –Bottom half: enabled interrupts, does most of the work

26 Device Drivers (1) Logical position of device drivers is shown here Communication between drivers and device controllers over the bus

27 Device Drivers (2) Classically we distinguish two types –Block devices (disks..) –Character devices (keyboards, printers..) Handles (typically) –Abstract requests “reads” and “writes” –Communication with device controller –Initialization –Power management

28 Device-Independent I/O Software (1) Functions of the device-independent I/O software Uniform interfacing for device drivers Buffering Error reporting Allocating and releasing dedicate devices Providing a device-independent block size Generic I/O management in the kernel

29 Uniform Interfacing for Device Drivers (a) Without a standard driver interface (b) With a standard driver interface

30 Device-Independent I/O Software (3) How are devices addressed? UNIX/Linux –Major number Identifying the device driver –Minor number Identifying the virtual device

31 Linux Driver Registration Drivers (modules) need to register with the kernel Kernel keeps table of drivers Special kernel routines for adding/deleting entries

32 Buffering Where to put the buffers –User –Kernel What if the buffer is full? How many buffers? When to tell the user app?

33 Device-Independent I/O Software (a) Unbuffered input (b) Buffering in user space (c) Buffering in the kernel followed by copying to user space (d) Double buffering in the kernel

34 I/O Buffering Where to store data to be sent? –User buffer Locking? When finished? –Kernel buffer No locking –Device controller

35 Device-Independent I/O Software Networking may involve many copies

36 User-Space I/O Software Layers of the I/O system and the main functions of each layer filesystem

37 More I/O Read more about disks, clocks, terminals etc. in Tanenbaum Disks: –Slow –Block size (transfer unit) Read about RAID 0-5! (Tanenbaum ) –Covered in the exercise

38 Redundant Array of Independent Disks (RAID)

39 File Systems UNIX: Everything is a file! Main memory is not enough –Persistency –Not large enough –Need a structuring of “data”

40 Long-term Information Storage 1.Must store large amounts of data 2.Information stored must survive the termination of the process using it 3.Multiple processes must be able to access the information concurrently  Store information on disks and other external media in units called files  Filesystem: OS Part that manages files

41 File Naming Typical file extensions

42 File Structure Three common ways how OS structures files a) byte sequence b) record sequence c) Tree (records of varied length, key field)

43 File Types Regular Files –ASCII –binary (a) executable (b) archive Directories Character special files Block special files

44 File Access Sequential access (early OS) –read all bytes/records from the beginning –cannot jump around, could rewind or back up –convenient when medium was magnetic tape Random access (modern OS) –bytes/records read in any order –essential for many app., e.g., database –read can be … move file marker (seek) and then read, or read and then move file marker

45 File Attributes Possible file attributes (also metadata)

46 File Operations 1.Create 2.Delete 3.Open 4.Close 5.Read 6.Write 7.Append 8.Seek 9.Get attributes 10.Set attributes 11.Rename 12.Lock

47 An Example Program Using File System Calls (1/2)

48 An Example Program Using File System Calls (2/2)

49 Memory-Mapped Files Accessing files using read/writes is sometimes cumbersome Alternative: map the whole file in memory Access the memory directly

50 Memory-Mapped Files (a) Segmented process before mapping files into its address space (b) Process after mapping existing file abc into one segment creating new segment for xyz

51 Hierarchical Directory Systems A hierarchical directory system

52 Directory Structure Notice the difference between Windows and UNIX –Windows: different partitions (volumes) are visible (A:,B:,C:, …) –UNIX: filesystems are mounted in one directory tree

53 A UNIX directory tree Path Names

54 Directory Operations 1.Create 2.Delete 3.Opendir 4.Closedir 5.Readdir 6.Rename 7.Link 8.Unlink