• Aucun résultat trouvé

Unit OS6: Device Management Unit OS6: Device Management

N/A
N/A
Protected

Academic year: 2022

Partager "Unit OS6: Device Management Unit OS6: Device Management"

Copied!
17
0
0

Texte intégral

(1)

Unit OS6: Device Management Unit OS6: Device Management

6.1.6.1. Principles of I/O SystemsPrinciples of I/O Systems

(2)

Copyright Notice Copyright Notice

© 2000-2005 David A. Solomon and Mark Russinovich

© 2000-2005 David A. Solomon and Mark Russinovich

These materials are part of the

These materials are part of the Windows Operating Windows Operating System Internals Curriculum Development Kit,

System Internals Curriculum Development Kit, developed by David A. Solomon and Mark E.

developed by David A. Solomon and Mark E.

Russinovich with Andreas Polze Russinovich with Andreas Polze

Microsoft has licensed these materials from David Microsoft has licensed these materials from David Solomon Expert Seminars, Inc. for distribution to Solomon Expert Seminars, Inc. for distribution to academic organizations solely for use in academic academic organizations solely for use in academic environments (and not for commercial use)

environments (and not for commercial use)

(3)

Roadmap for Section 6.1 Roadmap for Section 6.1

Principles of I/O Hardware Principles of I/O Hardware Structuring of I/O Software Structuring of I/O Software

Layers of an I/O System Layers of an I/O System

Operation of an I/O System

Operation of an I/O System

(4)

Input/

Input/ O O utput – utput –

Principles of I/O Hardware Principles of I/O Hardware

Major components of a computer system:

Major components of a computer system:

CPU, memories (primary/secondary), I/O system CPU, memories (primary/secondary), I/O system I/O devices:

I/O devices:

Block devices – store information in fixed-sized blocks;

Block devices – store information in fixed-sized blocks;

typical sizes: 128-1024 bytes typical sizes: 128-1024 bytes

Character devices – delivers/accepts stream of characters Character devices – delivers/accepts stream of characters

Device controllers:

Device controllers:

Connects physical device to system bus (Minicomputers, PCs) Connects physical device to system bus (Minicomputers, PCs) Mainframes use a more complex model:

Mainframes use a more complex model:

Multiple buses and specialized I/O computers (I/O channels) Multiple buses and specialized I/O computers (I/O channels)

Communication:

Communication:

Memory-mapped I/O, controller registers Memory-mapped I/O, controller registers Direct Memory Access - DMA

Direct Memory Access - DMA

(5)

I/O Hardware - Single Bus I/O Hardware - Single Bus

CPU Memory Video

Controller

Keyboard Controller

Floppy Controller

Disk Controller

System bus System bus

Monitor

Monitor KeyboardKeyboard FloppyFloppy drive

drive DiskDisk drive drive

(6)

I/O Hardware - Multiple Buses I/O Hardware - Multiple Buses

Video controller

Network controller

IDE disk controller

USB interface

keyboard mouse

CPU PCI bridge/

memory controller

Memory

Cache

SCSI controller

SCSI disk SCSI disk SCSI disk

PCI bus PCI bus

USB bus USB bus

SCSI bus SCSI bus Memory bus

Memory bus

(7)

Diversity among I/O Devices Diversity among I/O Devices

The I/O subsystem has to consider device characteristics:

The I/O subsystem has to consider device characteristics:

Data rate:

Data rate:

may vary by several orders of magnitude may vary by several orders of magnitude

Complexity of control:

Complexity of control:

exclusive vs. shared devices exclusive vs. shared devices

Unit of transfer:

Unit of transfer:

stream of bytes vs. block-I/O stream of bytes vs. block-I/O

Data representations:

Data representations:

character encoding, error codes, parity conventions character encoding, error codes, parity conventions

Error conditions:

Error conditions:

consequences, range of responses consequences, range of responses

Applications:

Applications:

impact on resource scheduling, buffering schemes impact on resource scheduling, buffering schemes

(8)

Organization of the I/O Function Organization of the I/O Function

Programmed I/O with polling:

Programmed I/O with polling:

The processor issues an I/O command on behalf of a process The processor issues an I/O command on behalf of a process The process busy waits for completion of the operation before The process busy waits for completion of the operation before proceeding

proceeding

Interrupt-driven I/O:

Interrupt-driven I/O:

The processor issues an I/O command and continues to execute The processor issues an I/O command and continues to execute The I/O module interrupts the processor when it has finished I/O The I/O module interrupts the processor when it has finished I/O The initiator process may be suspended pending the interrupt The initiator process may be suspended pending the interrupt

Direct memory access (DMA):

Direct memory access (DMA):

A DMA module controls exchange of data between I/O module and A DMA module controls exchange of data between I/O module and main memory

main memory

The processor requests transfer of a block of data from DMA and is The processor requests transfer of a block of data from DMA and is interrupted only after the entire block has been transferred

interrupted only after the entire block has been transferred

(9)

Flow of a blocking I/O request Flow of a blocking I/O request

Thread issues blocking read() Thread issues blocking read()

system call system call

Kernel checks parameters; may Kernel checks parameters; may

return buffered data and finish return buffered data and finish

Thread is removed from run Thread is removed from run

queue if physical I/O required;

queue if physical I/O required;

added to wait queue for device;

added to wait queue for device;

I/O request is scheduled I/O request is scheduled

Device driver allocates kernel Device driver allocates kernel

buffer; sends command to buffer; sends command to

controller controller

Device controller operates the Device controller operates the

hardware to perform data transfer hardware to perform data transfer

6.6. Driver may poll for status and Driver may poll for status and data; or set up DMA that will data; or set up DMA that will generate interrupt

generate interrupt

7.7. Interrupt occurs; handler stores Interrupt occurs; handler stores data; signals device driver

data; signals device driver

8.8. Device driver receives signal; Device driver receives signal;

determines request status;

determines request status;

signals kernel I/O subsystem signals kernel I/O subsystem 9.9. Kernel transfers data or return Kernel transfers data or return

code to user space; removes code to user space; removes thread from wait queue

thread from wait queue

10.10. Thread resumes execution at Thread resumes execution at completion of read() call

completion of read() call

(10)

Principles of I/O Software Principles of I/O Software

Layered organization Layered organization Device independence Device independence

Error handling Error handling

Error should be handled as close to the Error should be handled as close to the hardware as possible

hardware as possible

Transparent error recovery at low level Transparent error recovery at low level

Synchronous vs. Asynchronous transfers Synchronous vs. Asynchronous transfers

Most physical I/O is asynchronous Most physical I/O is asynchronous

Kernel may provide synchronous I/O system calls Kernel may provide synchronous I/O system calls

Sharable vs. dedicated devices Sharable vs. dedicated devices

Disk vs. printer Disk vs. printer

Structuring of I/O software

1. User-level software 2. Device-independent

OS software 3. Device drivers 4. Interrupt handlers

(11)

Interrupt Handlers Interrupt Handlers

Should be hidden by the operating system Should be hidden by the operating system

Every thread starting an I/O operation should block until Every thread starting an I/O operation should block until I/O has completed and interrupt occurs

I/O has completed and interrupt occurs

Interrupt handler transfers data from device (controller) Interrupt handler transfers data from device (controller) and un-blocks process

and un-blocks process

(12)

Device Driver Device Driver

Contains all device-dependent code Contains all device-dependent code Handles one device

Handles one device

Translates abstract requests into device commands Translates abstract requests into device commands

Writes controller registers Writes controller registers

Accesses mapped memory Accesses mapped memory

Queues requests Queues requests

Driver may block after issuing a request:

Driver may block after issuing a request:

Interrupt will un-block driver (returning status information) Interrupt will un-block driver (returning status information)

(13)

Device-independent I/O Software Device-independent I/O Software

Functions of device-independent I/O software:

Functions of device-independent I/O software:

Uniform interfacing for the device drivers Uniform interfacing for the device drivers Device naming

Device naming Device protection Device protection

Providing a device-independent block size Providing a device-independent block size Buffering

Buffering

Storage allocation on block devices Storage allocation on block devices

Allocating and releasing dedicated devices Allocating and releasing dedicated devices Error reporting

Error reporting

(14)

Layers of the I/O System Layers of the I/O System

User-Space I/O Software User-Space I/O Software

System call libraries System call libraries (read, write,...)

(read, write,...) Spooling

Spooling

Managing dedicated I/O Managing dedicated I/O devices in a

devices in a

multiprogramming system multiprogramming system Daemon process,

Daemon process, spooling directory spooling directory

lpd – line printer daemon, lpd – line printer daemon, sendmail – simple mail sendmail – simple mail transfer protocol

transfer protocol

Layer

User process Device-independent

software Device drivers Interrupt handlers

Hardware

I/O

request I/O

reply

I/O functions

I/O calls, spooling format I/O

Naming, protection buffering, blocking Setup registers, Check status Setup registers, Check status Wakeup driver Perform I/O op.

(15)

Application I/O Interfaces Application I/O Interfaces

The OS system call interface distinguished device classes:

The OS system call interface distinguished device classes:

Character-stream or block Character-stream or block

Sequential or random-access Sequential or random-access Synchronous or asynchronous Synchronous or asynchronous Sharable or dedicated

Sharable or dedicated Speed of operation Speed of operation

Read/write, read only, write only Read/write, read only, write only

(16)

Example:

Example:

4.3 BSD kernel I/O structure 4.3 BSD kernel I/O structure

The hardware socket Plain file

protocols File system

Cooked block interface

Raw block interface

Raw tty interface

cooked TTY Line discipline Network

interface Block-device driver character-device driver System-call interface to the kernel

(17)

Further Reading Further Reading

Abraham Silberschatz, Peter B. Galvin, Operating Abraham Silberschatz, Peter B. Galvin, Operating System Concepts, John Wiley & Sons, 6th Ed., 2003;

System Concepts, John Wiley & Sons, 6th Ed., 2003;

Chapter 2 - Computer-System Structures Chapter 2 - Computer-System Structures

Chapter 13 - I/O Systems Chapter 13 - I/O Systems

Références

Documents relatifs

For wideband data applications, such as FM video and satellite receivers, the drive to the detector can be increased with additional extemal capacitors between these

Programming with UNIX® System Calls Character User Interface Programming Graphical User Interface Programming Network Programming Interfaces Portable Device Interface (POI)

To that end, in this section we try to extensively consider the backhaul network and related limitations while ex- tracting the optimal association rules, and include to our goals

When an open succeeds the object manager creates a file object to When an open succeeds the object manager creates a file object to represent the open instance of the device and

Use Winobj to view driver objects in the \Device directory Use Winobj to view driver objects in the \Device directory.5. Lab: Device Name Mappings Lab: Device

Should Buyer purchase or use Motorola products for any such unintended or unauthorized application, Buyer shall indemnify and hold Motorola and its officers, employees,

Should Buyer purchase or use Motorola products for any such unintended or unauthorized application, Buyer shall indemnify and hold Motorola and its officers, employees,

Should Buyer purchase or use Motorola products for any such unintended or unauthorized application, Buyer shall indemnify and hold Motorola and its officers, employees,