Ausgewählte Betriebssysteme - Mark Russinovich & David Solomon (used with permission of authors)

Similar documents
Windows Interrupts

Process and Thread Management

Outline. Process and Thread Management. Data Structures (2) Data Structures. Kernel Process Block (PCB)

Introduction to I/O. 1-Slide Overview to File Management

DRIVER MODEL ULB Darmstadt

Windows 7 Overview. Windows 7. Objectives. The History of Windows. CS140M Fall Lake 1

Universal Windows Driver Development with WDF UMDF 2.0 and KMDF for IoT, Desktop and Server

Windows History 2009 Windows 7 2

Case Study. Windows XP. Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze

CSE 4/521 Introduction to Operating Systems. Lecture 29 Windows 7 (History, Design Principles, System Components, Programmer Interface) Summer 2018

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

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

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

KOSR 22 차세미나. KOSR 연역및소개 t h K o r e a O p e r a t i n g S y s t e m S e m e n a r

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

Operating Systems 2010/2011

I/O Systems. Jo, Heeseung

Device-Functionality Progression

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

Operating System Design Issues. I/O Management

Tape Channel Analyzer Windows Driver Spec.

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

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.

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

Machines and Virtualization. Systems and Networks Jeff Chase Spring 2006

IsoStack Highly Efficient Network Processing on Dedicated Cores

Lecture 15: I/O Devices & Drivers

Silberschatz and Galvin Chapter 12

I/O Management Software. Chapter 5

Module 22: Windows XP. Chapter 22: Windows XP. Objectives. Windows XP. History. Design Principles

Chapter 22: Windows XP

Module 21: Windows 2000

Module 21: Windows 2000

Outline. Security. Security Ratings. TCSEC Rating Levels. Key Requirements for C2. Met B-Level Requirements

Memory Protection. Machines and Virtualization. Architectural Foundations of OS Kernels. Memory and the CPU. Introduction to Virtual Addressing

T : Malware Analysis and Antivirus Technologies Windows Operating System

Security. Outline. Security Ratings. Ausgewählte Betriebssysteme Institut Betriebssysteme Fakultät Informatik

From last time. What is the maximum size of a file in bytes? What is the maximum total size of directories and files in a single disk partition?

Module 23: Windows NT. Windows NT

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

Module 23: Windows NT

I/O Management Software. Chapter 5

Appendix C: Windows Operating System Concepts Essentials 8 th Edition

Input Output (IO) Management

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

IT 540 Operating Systems ECE519 Advanced Operating Systems

Chapter 13: I/O Systems

Chapter 13: I/O Systems

Inter-Process Communication and Synchronization of Processes, Threads and Tasks: Lesson-1: PROCESS

Unit OS2: Operating System Principles. Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze

ESC(LP)-100. Eight Channel Low Profile RS-232 Asynchronous Communications Adapter. for PCI bus. User's Manual

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

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads

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

Outline of Lectures. Ausgewählte Betriebssysteme Windows 2000 & Linux. Resources for these Lectures. Windows An Introduction.

Outline of Lectures. Ausgewählte Betriebssysteme Windows 2000 & Linux. Resources for these Lectures. Windows An Introduction

Ausgewählte Betriebssysteme Windows 2000 & Linux

Chapter 13: I/O Systems

Chapter 1 Storage Drivers

Scuola Superiore Sant Anna. I/O subsystem. Giuseppe Lipari

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

Ausgewählte Betriebssysteme

Windows Kernel Internals II Overview University of Tokyo July 2004*

Chapter 13: I/O Systems

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

Chapter 5 - Input / Output

Chapter 4: Threads. Operating System Concepts. Silberschatz, Galvin and Gagne

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

[08] IO SUBSYSTEM 1. 1

Module 12: I/O Systems

CSCE Introduction to Computer Systems Spring 2019

Process Scheduling Queues

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

Module 12: I/O Systems

3.1 Introduction. Computers perform operations concurrently

Hardware OS & OS- Application interface

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

Multimedia Systems 2011/2012

ECE 485/585 Microprocessor System Design

Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads. Operating System Concepts

I/O SYSTEMS. Sunu Wibirama

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)

Operating Systems 2 nd semester 2016/2017. Chapter 4: Threads

Computer Architecture CS 355 Busses & I/O System

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

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

Common Computer-System and OS Structures

Module 11: I/O Systems

QSC(LP)-100. User's Manual

Chapter 4: Threads. Operating System Concepts 9 th Edit9on

Chapter 5 Input/Output. I/O Devices

Principles of Operating Systems CS 446/646

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

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

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

Chapter 4: Threads. Operating System Concepts 9 th Edition

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

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

CS370 Operating Systems

Transcription:

Outline Windows 2000 - The I/O Structure Ausgewählte Betriebssysteme Institut Betriebssysteme Fakultät Informatik Components of I/O System Plug n Play Management Power Management I/O Data Structures File Object Driver Object Device Object IRPs / DPCs 2 Components of the I/O System 3 Mark Russinovich & Windows David Solomon 2000 The (used I/O Structure with permission of authors) 4 Overview Overview (2) I/O Manager: Connects applications and system components to devices Defines infrastructure Device Driver: Provides I/O interface for particular device PnP Manager: Guide allocation of HW resources Detect and respond to arrival and removal of devices Power Manager: Guides system and device drivers through power-state transitions Windows Management Instrumentation (WMI): Support routines, which allow drivers to act as Windows Driver Model (WDM) WMI providers Registry: Stores description of basic hardware devices INF files: Driver installation files Link hardware device and driver HAL: Provides API to hide platform differences Is bus driver for driver-less devices on motherboard 5 6 1

Overview (3) I/O is performed on virtual files All data is regarded as stream of bytes Typical flow of I/O request (see picture) picture Mark Russinovich & David Solomon (used with Windows permission 2000 The of I/O authors) Structure 7 8 I/O Manager Device Drivers I/O system is packet-driven (I/O request packet IRP) Creates IRP and passes reference to driver and disposes it after completion Driver receives IRP, performs specified action and passes IRP back Supplies common code (e.g. Call another driver, time-out support,...) Uniform, modular interface of drivers allows I/O manager to call driver without special knowledge about driver Must conform to implementation guidelines Kernel mode device drivers File system drivers (direct file I/O requests to mass storage) Windows 2000 drivers (mass storage, protocol stacks,...) Legacy drivers (NT driver w/o power mngt., PnP) Win32 subsystem display drivers (translate device independent graphic into device dependant) WDM drivers (adhere to WDM = W2K drivers + WMI) User mode device drivers Virtual device drivers: emulate 16-bit MS-DOS applications Win32 subsystem printer drivers 9 10 WDM drivers Functional separation Source code compatible between Windows 2000, Windows 98, Windows Me, Windows XP Bus drivers: Manage logical or physical bus Responsible for detecting devices and reporting to PnP manager Manages power settings of bus Function drivers: Exports operational interface of device to OS Filter driver: Layer above or below function drivers Class driver: implement I/O processing for specific class of devices (disk, tape,...) Port driver: implement I/O processing for specific port type (SCSI,...) Mostly implemented as kernel-mode library Miniport driver: Map generic I/O request to type of port into adapter type 11 12 2

Layered Device Drivers normal layered drivers connect to lower and higher driver transparent drivers slip in between lower-layer driver and its clients: has to mimic behavior of lower driver virtual or logical device layers: expose virtual or logical device objects (e.g. named pipe) Layered Device Drivers (2) Call lower layer driver: retrieve stack location for next lower driver set up stack location (function code, parameters) associate completion routine with IRP to be informed when lower driver completes send IRP to lower driver (is asynchronous call) mark IRP pending Complete request Create new IRPs to pass to lower drivers 13 14 Layering example Example (2) 15 Windows (used 2000 with The permission I/O Structureof authors) 16 Driver Object Key Device Driver Routines Unique object for each loaded driver Consist of set of routines Routines process various stages of an I/O request e.g. load, unload, start I/O, etc. Linked list of device object, serviced by driver I/O Manager uses back pointer to find driver for object Driver removes device objects during unload 17 Initialization routine (when loading a driver) Add-device routine (PnP) Dispatch routines (process IRPs) Start I/O routine (initiate data transfer via I/O manager) Interrupt service routine (ISR executed when interrupt occurs, queues DPC) Interrupt-servicing DPC routine (DPC: deferred procedure call = interrupt handling at lower IRQL) 18 3

Key Device Driver Routines (2) I/O completion routines (used to notify stacked drivers of I/O completion) Cancel I/O routine (cancel IRP processing) Unload routine (release system resources) System shutdown notification routine (called before system shuts down) Error-logging routine (write errors to error-log) Outline Components of I/O System Plug n Play Management Power Management I/O Data Structures File Object Driver Object Device Object IRPs / DPCs 19 20 Plug and Play Manager Automatically recognizes installed devices (enumerates devices during boot process, detect addition or removal) Hardware resource allocation and reallocation for devices (interrupts, DMA addresses, etc.) Load appropriate drivers: Determine driver and instruct I/O Manager to load If none found install driver via user-mode PnP manager Found new Hardware P n P Manager (2) Implements mechanisms for applications and drivers to detect configuration changes (notification) Support level depends on attached devices and installed drivers 21 22 Device PnP state transitions P n P state transitions Pending remove: Finish pending I/O requests Do not accept further I/O requests Power down device Surprise remove: Immediately stop running I/O requests Remove pending I/O requests 23 24 4

Outline Components of I/O System Plug n Play Management Power Management I/O Data Structures File Object Driver Object Device Object IRPs / DPCs Power Management Requires hardware that complies with Advanced Configuration and Power Interface (ACPI) specification 6 system power states Power manager request driver to move to other power state If driver is busy it rejects request system stays at current power level 25 26 Power Management (2) ACPI standard and Win2K Multiple driver objects associated with one device: Only one driver designated as device power-policy owner Decides device s power state based on system power state Asks power manager to inform other drivers Thus power manager can control number of power commands in system (e.g. number of devices powering up) Defines various power levels for: System: S0 (fully on) S5 (fully off) Devices: D0 (fully on) D3 (fully off) D1 and D2 are free to be defined by device Driver reports supported power level to PnP manager at load time Bus driver provides mapping from system power states to device power states 27 28 Outline File objects Components of I/O System Plug n Play Management Power Management I/O Data Structures File Object Driver Object Device Object IRPs / DPCs Kernel-mode construct for handles to files or devices Provide memory-based representation of resources which can be read or written Protected by security descriptor (including ACL) Contains data unique to object handle (byte offset,...) Every time a new file handle is opened a new file object is created File object is unique to process, except: Child inherits from parent Duplicate handle to another process 29 30 5

Opening a file object Device and Driver Objects Driver object: Represents an individual driver I/P manager obtains address of dispatch routines from it Device object: Represents physical or logical device and its characteristics (e.g. buffer alignment and location of device queue for IRPs) Driver creates device object when PnP manager informs it Driver may export a name for device to allow applications to open it One driver can have multiple device objects Device objects have back-link to driver 31 32 Device and Driver Objects (2) IRP Header contains (fixed part): Type and size of request Synchronous or asynchronous request Pointer to buffer for buffered I/O State information 33 34 IRP (2) IRP (2) Stack location contains (one or more): Function code and parameters (identifies driver s dispatch routine) Pointer to caller s file object Used to find answer point for layered drivers (I/O completion routine) Number of stack locations determined by number of driver layers 35 36 6

IRP Buffer Management IRP Buffer Management (2) I/O Manager perform three types of I/O buffer management: Buffered I/O: I/O manager allocates memory from non-paged pool and copies data from/to user s buffer Direct I/O: user s buffer is locked by I/O manager (DMA) Neither I/O: I/O manager does not do any buffer management (driver might do it) Driver registers type of buffer management in device object 37 Drivers usually use buffered I/O if smaller than one page (4KB) copy operation = overhead of memory lock File systems driver usually use Neither I/O, because no buffer management needed for copy from/to file system cache 38 I/O Completion Ports Introduced for servers with multiple parallel threads Threads wait for I/O packets to arrive at port System controls number of currently running threads (should be the same as number of processors) Can be regarded as thread pool Driver Loading/Initialization Enumeration-based loading: PnP manager dynamically loads drivers for devices that bus driver reports Explicit loading: is guided by HKLM\SYSTEM\CurrentControlSet\Services Registry key Start value: 0 at boot time (loaded by System) 1 after initialization (loaded by I/O manager) 2 auto-start (after System started) 3 demand-start (started when first called) 39 40 Types of I/O Types of I/O (2) Synchronous I/O: Application waits for I/O to complete I/O manager mimics synchronous behavior to application Asynchronous I/O: Allows application to continue APC is queued after completion Has to synchronize with completion of I/O using a synchronization object Fast I/O: Special mechanism, that bypasses IRP generation Entry points have to be registered in driver object Used to signal completed I/O request E.g. used by File System to check if file is in file cache 41 42 7

Types of I/O (3) I/O to Single-Layered Driver Mapped File I/O and File Caching File (or parts of it) loaded into memory, and paging mechanism does I/O Mapped Files used by Cache Manager Scatter/Gather I/O Allow single read or write from multiple buffers in memory to a contiguous area on disk Buffers have to be page aligned I/O must be aligned on device sector boundary 43 44 Servicing an Interrupt Servicing an Interrupt (2) 45 46 Completing an I/O Request Completing an I/O Request (2) 47 48 8

Completing Layered I/O I/O to Layered Driver Ausgewählte (used Betriebssysteme with permission - of authors) 49 Windows (used 2000 with The permission I/O Structure of authors) 50 Synchronization Drivers have to synchronize using kernel-synchronization routines On single processor by raising IRQL On multiple processors also using spin locks 51 9