Chapter05 Input Output
Chapter05 Input Output
Chapter 5
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
I/O Devices (1)
• Block devices
– Stores information in fixed-size blocks
– Transfers are in units of entire blocks
• Character devices
– Delivers or accepts stream of characters, without
regard to block structure
– Not addressable, does not have any seek
operation
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
I/O Devices (2)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Memory-Mapped I/O (1)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Interrupts Revisited
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Goals of the I/O Software
Issues:
•Device independence
•Uniform naming
•Error handling
•Synchronous versus asynchronous
•Buffering.
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Programmed I/O (1)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Programmed I/O (2)
Figure 5-10. Printing a string using DMA. (a) Code executed when
the print system call is made. (b) Interrupt service procedure.
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
I/O Software Layers
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Interrupt Handlers (1)
Typical steps after hardware interrupt completes:
1.Save registers (including the PSW) not already saved
by interrupt hardware.
2.Set up context for interrupt service procedure.
3.Set up a stack for the interrupt service procedure.
4.Acknowledge interrupt controller. If no centralized
interrupt controller, reenable interrupts.
5.Copy registers from where saved to process table.
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Interrupt Handlers (2)
Typical steps after hardware interrupt completes:
6.Run interrupt service procedure. Extract information
from interrupting device controller’s registers.
7.Choose which process to run next.
8.Set up the MMU context for process to run next.
9.Load new process’ registers, including its PSW.
10.Start running the new process.
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Device Drivers
Figure 5-15. (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.
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Buffering (2)
Figure 5-18. Disk parameters for the original IBM PC 360-KB floppy
disk and a Western Digital WD 3000 HLFS (‘‘Velociraptor’’) hard disk.
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Magnetic Disks (2)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
RAID (2)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Disk Formatting (1)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Disk Formatting (2)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Disk Arm Scheduling Algorithms (2)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Error Handling
Figure 5-26. (a) A disk track with a bad sector. (b) Substituting a spare
for the bad sector. (c) Shifting all the sectors to bypass the bad one.
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Stable Storage (1)
• Uses pair of identical disks
• Either can be read to get same results
• Operations defined to accomplish this:
1. Stable Writes
2. Stable Reads
3. Crash recovery
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Stable Storage (2)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Hardware
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Software (1)
Typical duties of a clock driver:
1.Maintaining the time of day.
2.Preventing processes from running longer than
allowed.
3.Accounting for CPU usage.
4.Handling alarm system call from user processes.
5.Providing watchdog timers for parts of system itself.
6.Profiling, monitoring, statistics gathering.
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Software (2)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Software (3)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Soft Timers
Soft timers stand or fall with the rate at which
kernel entries are made for other reasons. These
reasons include:
1. System calls.
2. TLB misses.
3. Page faults.
4. I/O interrupts.
5. The CPU going idle.
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Keyboard Software
Figure 5-32. The ANSI escape sequences accepted by the terminal driver on output. ESC
denotes the ASCII escape character (0x1B), and n, m, and s are optional numeric parameters.
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
The X Window System (1)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
The X Window System (3)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
The X Window System (4)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Graphical User Interfaces (1)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Graphical User Interfaces (3)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Graphical User Interfaces (4)
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Operating System Issues
The CPU
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
End
Chapter 5
Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.