1 / 81

Ch. 9 I/O System

Ch. 9 I/O System. 발표자 : 서우석 발표일 : 2006 년 11 월 6 일. 목차. I/O System Components Device Drivers I/O Processing The Plug and Play (PnP) Manager The Power Manager Conclusion. 목차. I/O System Components Device Drivers I/O Processing The Plug and Play (PnP) Manager The Power Manager

efia
Download Presentation

Ch. 9 I/O System

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ch. 9 I/O System 발표자: 서우석 발표일: 2006년 11월 6일

  2. 목차 • I/O System Components • Device Drivers • I/O Processing • The Plug and Play (PnP) Manager • The Power Manager • Conclusion

  3. 목차 • I/O System Components • Device Drivers • I/O Processing • The Plug and Play (PnP) Manager • The Power Manager • Conclusion

  4. Design Goal • Provide an abstraction of devices to apps. • Features • High performance asynchronous packet-based I/O • Services support High-Level language and different machine architecture • Layering and extensibility • Dynamic loading and unloading of device drivers • Support for Plug and Play • Support for power management • Support for multiple installable file systems • Windows Management Instrumentation

  5. I/O System Components

  6. I/O Manager • The Core of the I/O System • I/O System is packet driven • Presented by an I/O Request Packet (IRP) • Create  Passing  (Forwarding ) Disposing • Supply common code • Individual drivers become simpler and more compact. • Other features • Manages buffers for I/O requests • Provides timeout support • Records installable file systems • Common routines • Asynchronous I/O

  7. Typical I/O Processing • Abstracts all I/O requests as operations on a virtual file, even if it is not a file. • virtual files refers to any source or destination for I/O • open, close, read, write functions

  8. The flow of a typical I/O request

  9. 목차 • I/O System Components • Device Drivers • I/O Processing • The Plug and Play (PnP) Manager • The Power Manager • Conclusion

  10. Types of Device Drivers • user-mode drivers • Virtual device drivers to emulate 16-bit MS-DOS app • Printer drivers • kernel-mode drivers • File system drivers • Plug and Play drivers • Non–Plug and Play drivers • ex) network API and protocol drivers

  11. WDM Drivers • support for Windows power management, Plug and Play, and WMI • Types of WDM drivers • Bus drivers manage a logical or physical bus • ex) PCMCIA, PCI, USB, IEEE 1394, and ISA • detecting and informing the PnP manager of devices attached to the bus • Function drivers with the most knowledge about the operation of the device • Filter drivers logically layer above or below function drivers, augmenting or changing the behavior of a device or another driver • ex) keyboard capture driver

  12. Layered Drivers • Class drivers • implement the I/O processing for a particular class of devices, such as disk, tape, or CD-ROM • where the hardware interfaces have been standardized and so one driver can serve devices from a wide variety of manufacturers • Port drivers • implement the processing of an I/O request specific to a type of I/O port, such as SCSI • implemented as kernel-mode libraries of functions • Miniport drivers • map a generic I/O request to a type of port into an adapter type, such as a specific SCSI adapter

  13. Example: How device drivers work

  14. Example: Adding a layered driver

  15. EXPERIMENT: Viewing the Loaded Driver List

  16. Key driver-function routines initiate a data transfer to or from a device. This routine is defined only in drivers that rely on the I/O manager to queue its incoming I/O requests the main functions that a device driver provides When a device interrupts, the kernel's interrupt dispatcher transfers control to this routine. Only drivers for interrupt- driven devices have ISRs; a file system driver, for example, doesn't have one. The PnP manager sends a driver notification via this routine. driver typically allocates a device object DPC routine executes at a lower IRQL (DPC/dispatch level) than that of the ISR fills in system data structures to register the rest of the driver's routines with the I/O manager and performs any global driver initialization that's necessary

  17. Other routines • One or more I/O completion routines • notify it when a lower-level driver finishes processing an IRP • A cancel I/O routine • I/O operation can be canceled • An unload routine • I/O manager can remove drivers from memory • A system shutdown notification routine • allows driver cleanup on system shutdown • Error-logging routines • When unexpected errors occur (for example, when a disk block goes bad), a driver's error-logging routines note the occurrence and notify the I/O manager

  18. Driver Objects and Device Objects • driver object • represents an individual driver in the system • The I/O manager obtains the address of each of the driver's dispatch routines (entry points) from the driver object • device object • represents a physical or logical device on the system and describes its characteristics • Create driver object  calls the driver's initialization routine  create device objects to represent devices (Most PnP drivers create devices with add-device routines, optionally assign the device a name (\Device))  unload

  19. Location of Device object • Symbolic link • make it possible for applications to open the device object • in the \Global?? directory • Non–Plug and Play and file system drivers typically create a symbolic link with a well-known name • ex) \Device\Hardware2 • IoRegisterDeviceInterface • determines the symbolic link that is associated with a device instance • SetupDiEnumDeviceInterfaces • enumerate the interfaces present for a particular GUID and to obtain the names of the symbolic links • SetupDiGetDeviceInterfaceDetail • obtain additional information about the device

  20. EXPERIMENT: Looking at the \Device Directory

  21. The driver object

  22. EXPERIMENT: Displaying Driver and Device Objects

  23. Opening Devices • File objects • the kernel-mode constructs for handles to files or devices • system resources that two or more user-mode processes can share • have names • protected by object-based security • support synchronization

  24. File Object Attributes • FILE_OBJECT in Ntddk.h

  25. EXPERIMENT: Viewing the File Object Data Structure

  26. Opening a file object

  27. EXPERIMENT: Viewing Device Handles

  28. EXPERIMENT: Viewing Windows Device Name to Windows Device Name Mappings

  29. 목차 • I/O System Components • Device Drivers • I/O Processing • The Plug and Play (PnP) Manager • The Power Manager • Conclusion

  30. Synchronous I/O and Asynchronous I/O

  31. Fast I/O • bypass generating an IRP and instead go directly to the file system driver or cache manager to complete an I/O request. • A driver registers its fast I/O entry points by entering them in a structure pointed to by the PFAST_IO_DISPATCH pointer in its driver object

  32. EXPERIMENT: Looking at a Driver's Registered Fast I/O Routines

  33. Mapped File I/O and File Caching • the ability to view a file residing on disk as part of a process's virtual memory • CreateFileMapping and Map- ViewOfFile functions • File systems use the cache manager to map file data in virtual memory to provide better response time for I/O- bound programs

  34. Data structures involved in a single-layered driver I/O request

  35. EXPERIMENT: Looking at Driver Dispatch Routines

  36. EXPERIMENT: Looking at a Thread's Outstanding IRPs

  37. Queuing and completing a synchronous request

  38. Servicing a device interrupt (phase 1)

  39. Servicing a device interrupt (phase 2)

  40. Completing an I/O request (phase 1)

  41. Completing an I/O request (phase 2)

  42. Synchronization • The execution of a driver can be preempted by higher-priority threads and time-slice (or quantum) expiration or can be interrupted by interrupts • On multiprocessor systems, Windows can run driver code simultaneously on more than one processor • KeAcquireInterruptSpinLock

  43. Queuing an asynchronous request to layered drivers

  44. EXPERIMENT: Viewing a Device Stack

  45. EXPERIMENT: Examining IRPs

  46. Completing a layered I/O request

  47. Queuing associated IRPs

  48. Completing associated IRPs

  49. I/O Completion Ports

  50. Driver Verifier • looking for a number of illegal operations—including calling kernel-memory pool functions at invalid IRQL, double-freeing memory, and requesting a zero-sized memory allocation

More Related