I/O SYSTEMS
Sunu Wibirama
I/O SYSTEMS Sunu Wibirama Are you surely IT class member? Then - - PowerPoint PPT Presentation
I/O SYSTEMS Sunu Wibirama Are you surely IT class member? Then you should know these pictures... Introduction Main job of computer : I/O and processing (the latter is rarely happened) Browsing: read and enter information, not
Sunu Wibirama
13.
Main job of computer : I/O and processing (the latter is rarely happened)
Browsing: read and enter information, not compute an answer
OS: manage, control I/O devices and operations
We will explore:
I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware Operations STREAMS Performance
At the end of this presentation, we will talk about final assignment and final test (UAS)
13.
Major concern of OS designer is: I/O support
Incredible variety of I/O devices: mouse, hard disk, cd-rom, usb, etc.
Common concepts of I/O hardware elements:
Port / connection point (ex.: serial port, parallel port) Bus: wires with spesific protocol Controller (host adapter) - Serial-port controller v.s. SCSI controller
Details are encapsulated in device-driver module in OS kernel
Device drivers: uniform I/O instructions to control I/O devices
Controller has one or more registers for data and control signals
Devices have addresses, used by
Direct I/O instructions using bus: send instructions to an I/O port
address
Memory-mapped I/O: device-control registers are mapped into the
address space of the processor
13.
13.
13.
Data-in register: read by the host to get input
Data-out register: written by the host to send output
Status register: contain status bits that can be read by the host
Control register: can be written by the host to start command or to change the mode of the device. Example:
Full-duplex or half-duplex mode; Duplex: communicate (send and receive message). Half-duplex: only
information at the same time.
13.
Explain I/O host and I/O controller communication
Controller:
Status register: 1 - busy and 0 - clear
Host:
Command register: command-ready bit
Handshaking step (repeated for each byte):
Host repeatedly read busy bit until that bit becomes clear (busy waiting or polling) Host sets the write bit in the command register and writes a byte into the data-out
register
Host sets command-ready bit Controller notices that command-ready bit is set, it sets the busy bit Controller reads the command register, sees the write command. It reads data-out
register to get the byte and does the I/O to the device
Controller clears command-ready bit, clears error bit in the status register to
indicate I/O succeeded, clears the busy bit to indicate that I/O operation is finished
Busy-wait cycle to wait for I/O from device
More efficient, if the controller notify the CPU when itʼs ready to operate: interrupts
13.
13.
Interrupts-request line: receiving interrupts from I/O contoller
Nonmaskable interrupt: reserved for events such as unrecoverable memory errors.
Maskable to ignore or delay some interrupts
Interrupt mechanism accepts an address - a number that selects a specific interrupt-handling routine from a small set (the number is called interrupt-vector)
Interrupt-vector contains the memory address of specialized interrupt-handlers.
Interrupt mechanism uses interrupt priority level (low or high priority interrupt)
Interrupt mechanism also used for exceptions (such as: dividing by zero, accessing protected or nonexistent memory address, attempting to execute a privileged instruction from user mode).
13.
Large data transfer: disk drive
Used to avoid programmed I/O for large data movement (= watch status bits and to feed data into a controller register one byte at a time)
Requires DMA controller
Bypasses CPU to transfer data directly between I/O device and memory
13.
13.
Explain interface and techniques of OS to treat I/O devices in standard way (such as open a file on a disk without knowing what kind of disk it is).
I/O system calls encapsulate device behaviors in generic classes
Device-driver layer hides differences among I/O controllers from kernel
Devices vary in many dimensions
Character-stream or block Sequential or random-access Sharable or dedicated Speed of operation read-write, read only, or write only
13.
uniformity
think the structure as organization structure: head of organization doesn’t need to know the detail
13.
13.
Kernel provides many services to I/O, such as:
scheduling buffering caching spooling device reservation error handling
These are provided by I/O subsystem, build on hardware and device-driver infrastructure
13.
Scheduling
Meaning: to determine a good order to execute I/O requests Can improve overall system performance Some I/O request ordering via per-device queue Some OSs try fairness
Buffering - store data in memory while transferring between devices
To deal with device speed mismatch (modem v.s. storage) To deal with device transfer size mismatch (data re-assemble) To maintain “copy semantics” (data reliability when write() system call is
executed).
13.
13.
Caching - fast memory holding copy of data (do you remember the function of proxy
server in networking? - you need to press CTRL+F5 to renew the cache) Always just a copy (not the only existing item - as buffer does) Key to performance
Spooling - hold output for a device
If device can serve only one request at a time i.e., Printing - no interleave allowed
Device reservation - provides exclusive access to a device
System calls for allocation and deallocation Watch out for deadlock
13.
OS can recover from disk read, device unavailable or defective, transient write failures
Most return an error number or code when I/O request fails
Unix : errno 2 - no such file or directory
System error logs hold problem reports
13.
User process may accidentally or purposefully attempt to disrupt normal operation via illegal I/O instructions
All I/O instructions defined to
be privileged: I/O must be performed via OSʼ system calls
Memory-mapped and I/O
port memory locations must be protected too (ex.: graphic games and video editing should access the memory
block of memory for graphic processing at one time)
13.
Kernel keeps state info for I/O components, including open file tables, network connections, character device state
Many, many complex data structures to track buffers, memory allocation, “dirty” blocks
Unix uses object-oriented methods to encapsulate “differences” (for example: read() operation, the semantics is different for each I/O devices)
Windows uses message passing to implement I/O
I/O request is converted into a message through the kernel to the
I/O manager and then to device driver, each of which may change the message contents. For output, the message contains data to be written. For input, the message contains buffer to receive data.
13.
Consider reading a file from disk for a process:
Determine device holding file Translate name to device representation Physically read data from disk into buffer Make data available to requesting process Return control to process