SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Unit OS6: Device Management
6.1. Principles of I/O Systems
2
3
Roadmap for Section 6.1
Principles of I/O Hardware
Structuring of I/O Software
Layers of an I/O System
Operation of an I/O System
4
Input/Output –
Principles of I/O Hardware
Major components of a computer system:
CPU, memories (primary/secondary), I/O system
I/O devices:
Block devices – store information in fixed-sized blocks;
typical sizes: 128-1024 bytes
Character devices – delivers/accepts stream of characters
Device controllers:
Connects physical device to system bus (Minicomputers, PCs)
Mainframes use a more complex model:
Multiple buses and specialized I/O computers (I/O channels)
Communication:
Memory-mapped I/O, controller registers
Direct Memory Access - DMA
5
I/O Hardware - Single Bus
CPU Memory
Video
Controller
Keyboard
Controller
Floppy
Controller
Disk
Controller
System bus
Monitor Keyboard Floppy
drive
Disk
drive
6
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
USB bus
SCSI bus
Memory bus
7
Diversity among I/O Devices
The I/O subsystem has to consider device characteristics:
Data rate:
may vary by several orders of magnitude
Complexity of control:
exclusive vs. shared devices
Unit of transfer:
stream of bytes vs. block-I/O
Data representations:
character encoding, error codes, parity conventions
Error conditions:
consequences, range of responses
Applications:
impact on resource scheduling, buffering schemes
8
Organization of the I/O Function
Programmed I/O with polling:
The processor issues an I/O command on behalf of a process
The process busy waits for completion of the operation before
proceeding
Interrupt-driven I/O:
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 initiator process may be suspended pending the interrupt
Direct memory access (DMA):
A DMA module controls exchange of data between I/O module and
main memory
The processor requests transfer of a block of data from DMA and is
interrupted only after the entire block has been transferred
9
Flow of a blocking I/O request
1. Thread issues blocking read()
system call
2. Kernel checks parameters; may
return buffered data and finish
3. Thread is removed from run
queue if physical I/O required;
added to wait queue for device;
I/O request is scheduled
4. Device driver allocates kernel
buffer; sends command to
controller
5. Device controller operates the
hardware to perform data
transfer
6. Driver may poll for status and
data; or set up DMA that will
generate interrupt
7. Interrupt occurs; handler
stores data; signals device
driver
8. Device driver receives signal;
determines request status;
signals kernel I/O subsystem
9. Kernel transfers data or return
code to user space; removes
thread from wait queue
10. Thread resumes execution at
completion of read() call
10
Principles of I/O Software
Layered organization
Device independence
Error handling
Error should be handled as close to the
hardware as possible
Transparent error recovery at low level
Synchronous vs. Asynchronous transfers
Most physical I/O is asynchronous
Kernel may provide synchronous I/O system
calls
Sharable vs. dedicated devices
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
Should be hidden by the operating system
Every thread starting an I/O operation should block until
I/O has completed and interrupt occurs
Interrupt handler transfers data from device (controller)
and un-blocks process
12
Device Driver
Contains all device-dependent code
Handles one device
Translates abstract requests into device commands
Writes controller registers
Accesses mapped memory
Queues requests
Driver may block after issuing a request:
Interrupt will un-block driver (returning status information)
13
Device-independent I/O Software
Functions of device-independent I/O software:
Uniform interfacing for the device drivers
Device naming
Device protection
Providing a device-independent block size
Buffering
Storage allocation on block devices
Allocating and releasing dedicated devices
Error reporting
14
Layers of the I/O System
User-Space I/O Software
System call libraries
(read, write,...)
Spooling
Managing dedicated I/O
devices in a
multiprogramming
system
Daemon process,
spooling directory
lpd – line printer
daemon, sendmail –
simple mail 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
The OS system call interface distinguished device classes:
Character-stream or block
Sequential or random-access
Synchronous or asynchronous
Sharable or dedicated
Speed of operation
Read/write, read only, write only
16
Example:
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

Weitere ähnliche Inhalte

Ähnlich wie 6.1_IO-Principles.ppt

Operating System Case Study and I/O System
Operating System Case Study and I/O SystemOperating System Case Study and I/O System
Operating System Case Study and I/O Systemprakash ganesan
 
IO SYSTEM AND CASE STUDY STRUCTURE
IO SYSTEM AND CASE STUDY STRUCTUREIO SYSTEM AND CASE STUDY STRUCTURE
IO SYSTEM AND CASE STUDY STRUCTUREHariharan Anand
 
Chapter 6 input output
Chapter 6 input outputChapter 6 input output
Chapter 6 input outputrisal07
 
Computer architecture input output organization
Computer architecture input output organizationComputer architecture input output organization
Computer architecture input output organizationMazin Alwaaly
 
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptx
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptxFANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptx
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptxPannaBushratul
 
Operating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / OutputOperating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / OutputPeter Tröger
 
IO and file systems
IO and file systems IO and file systems
IO and file systems EktaVaswani2
 
discuss the drawbacks of programmed and interrupt driven io and des.pdf
discuss the drawbacks of programmed and interrupt driven io and des.pdfdiscuss the drawbacks of programmed and interrupt driven io and des.pdf
discuss the drawbacks of programmed and interrupt driven io and des.pdfinfo998421
 
Basic Organisation and fundamental Of Computer.pptx
Basic Organisation and fundamental Of Computer.pptxBasic Organisation and fundamental Of Computer.pptx
Basic Organisation and fundamental Of Computer.pptxhasanbashar400
 
COMPUTER BASIC AND FUNDAMENTAL AND ITS ORGANISATION.pptx
COMPUTER BASIC AND FUNDAMENTAL AND ITS ORGANISATION.pptxCOMPUTER BASIC AND FUNDAMENTAL AND ITS ORGANISATION.pptx
COMPUTER BASIC AND FUNDAMENTAL AND ITS ORGANISATION.pptxPannaBushratul
 
Ch # 04 computer hardware
Ch # 04 computer hardware Ch # 04 computer hardware
Ch # 04 computer hardware MuhammadRobeel3
 

Ähnlich wie 6.1_IO-Principles.ppt (20)

Operating System Case Study and I/O System
Operating System Case Study and I/O SystemOperating System Case Study and I/O System
Operating System Case Study and I/O System
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
Multimedia Technology
Multimedia TechnologyMultimedia Technology
Multimedia Technology
 
IO SYSTEM AND CASE STUDY STRUCTURE
IO SYSTEM AND CASE STUDY STRUCTUREIO SYSTEM AND CASE STUDY STRUCTURE
IO SYSTEM AND CASE STUDY STRUCTURE
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
07 Input Output
07  Input  Output07  Input  Output
07 Input Output
 
I/O Management
I/O ManagementI/O Management
I/O Management
 
Chapter 6 input output
Chapter 6 input outputChapter 6 input output
Chapter 6 input output
 
Computer architecture input output organization
Computer architecture input output organizationComputer architecture input output organization
Computer architecture input output organization
 
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptx
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptxFANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptx
FANDAMENTAL OF COMPUTER SCIENCE FOR ENGINEERING.pptx
 
IO_ORGANIZATION.pdf
IO_ORGANIZATION.pdfIO_ORGANIZATION.pdf
IO_ORGANIZATION.pdf
 
Operating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / OutputOperating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / Output
 
IO and file systems
IO and file systems IO and file systems
IO and file systems
 
I/O System
I/O SystemI/O System
I/O System
 
CH01.pdf
CH01.pdfCH01.pdf
CH01.pdf
 
Ch1
Ch1Ch1
Ch1
 
discuss the drawbacks of programmed and interrupt driven io and des.pdf
discuss the drawbacks of programmed and interrupt driven io and des.pdfdiscuss the drawbacks of programmed and interrupt driven io and des.pdf
discuss the drawbacks of programmed and interrupt driven io and des.pdf
 
Basic Organisation and fundamental Of Computer.pptx
Basic Organisation and fundamental Of Computer.pptxBasic Organisation and fundamental Of Computer.pptx
Basic Organisation and fundamental Of Computer.pptx
 
COMPUTER BASIC AND FUNDAMENTAL AND ITS ORGANISATION.pptx
COMPUTER BASIC AND FUNDAMENTAL AND ITS ORGANISATION.pptxCOMPUTER BASIC AND FUNDAMENTAL AND ITS ORGANISATION.pptx
COMPUTER BASIC AND FUNDAMENTAL AND ITS ORGANISATION.pptx
 
Ch # 04 computer hardware
Ch # 04 computer hardware Ch # 04 computer hardware
Ch # 04 computer hardware
 

Kürzlich hochgeladen

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...ranjana rawat
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 

Kürzlich hochgeladen (20)

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 

6.1_IO-Principles.ppt

  • 1. Unit OS6: Device Management 6.1. Principles of I/O Systems
  • 2. 2
  • 3. 3 Roadmap for Section 6.1 Principles of I/O Hardware Structuring of I/O Software Layers of an I/O System Operation of an I/O System
  • 4. 4 Input/Output – Principles of I/O Hardware Major components of a computer system: CPU, memories (primary/secondary), I/O system I/O devices: Block devices – store information in fixed-sized blocks; typical sizes: 128-1024 bytes Character devices – delivers/accepts stream of characters Device controllers: Connects physical device to system bus (Minicomputers, PCs) Mainframes use a more complex model: Multiple buses and specialized I/O computers (I/O channels) Communication: Memory-mapped I/O, controller registers Direct Memory Access - DMA
  • 5. 5 I/O Hardware - Single Bus CPU Memory Video Controller Keyboard Controller Floppy Controller Disk Controller System bus Monitor Keyboard Floppy drive Disk drive
  • 6. 6 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 USB bus SCSI bus Memory bus
  • 7. 7 Diversity among I/O Devices The I/O subsystem has to consider device characteristics: Data rate: may vary by several orders of magnitude Complexity of control: exclusive vs. shared devices Unit of transfer: stream of bytes vs. block-I/O Data representations: character encoding, error codes, parity conventions Error conditions: consequences, range of responses Applications: impact on resource scheduling, buffering schemes
  • 8. 8 Organization of the I/O Function Programmed I/O with polling: The processor issues an I/O command on behalf of a process The process busy waits for completion of the operation before proceeding Interrupt-driven I/O: 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 initiator process may be suspended pending the interrupt Direct memory access (DMA): A DMA module controls exchange of data between I/O module and main memory The processor requests transfer of a block of data from DMA and is interrupted only after the entire block has been transferred
  • 9. 9 Flow of a blocking I/O request 1. Thread issues blocking read() system call 2. Kernel checks parameters; may return buffered data and finish 3. Thread is removed from run queue if physical I/O required; added to wait queue for device; I/O request is scheduled 4. Device driver allocates kernel buffer; sends command to controller 5. Device controller operates the hardware to perform data transfer 6. Driver may poll for status and data; or set up DMA that will generate interrupt 7. Interrupt occurs; handler stores data; signals device driver 8. Device driver receives signal; determines request status; signals kernel I/O subsystem 9. Kernel transfers data or return code to user space; removes thread from wait queue 10. Thread resumes execution at completion of read() call
  • 10. 10 Principles of I/O Software Layered organization Device independence Error handling Error should be handled as close to the hardware as possible Transparent error recovery at low level Synchronous vs. Asynchronous transfers Most physical I/O is asynchronous Kernel may provide synchronous I/O system calls Sharable vs. dedicated devices Disk vs. printer Structuring of I/O software 1. User-level software 2. Device-independent OS software 3. Device drivers 4. Interrupt handlers
  • 11. 11 Interrupt Handlers Should be hidden by the operating system Every thread starting an I/O operation should block until I/O has completed and interrupt occurs Interrupt handler transfers data from device (controller) and un-blocks process
  • 12. 12 Device Driver Contains all device-dependent code Handles one device Translates abstract requests into device commands Writes controller registers Accesses mapped memory Queues requests Driver may block after issuing a request: Interrupt will un-block driver (returning status information)
  • 13. 13 Device-independent I/O Software Functions of device-independent I/O software: Uniform interfacing for the device drivers Device naming Device protection Providing a device-independent block size Buffering Storage allocation on block devices Allocating and releasing dedicated devices Error reporting
  • 14. 14 Layers of the I/O System User-Space I/O Software System call libraries (read, write,...) Spooling Managing dedicated I/O devices in a multiprogramming system Daemon process, spooling directory lpd – line printer daemon, sendmail – simple mail 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. 15 Application I/O Interfaces The OS system call interface distinguished device classes: Character-stream or block Sequential or random-access Synchronous or asynchronous Sharable or dedicated Speed of operation Read/write, read only, write only
  • 16. 16 Example: 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. 17