1. Driver-Kernel Interface
1.1. • Drivers are distinct from main part of kernel
1.2. • Kernel makes calls on specific functions, drivers implement them
1.3. • Drivers use kernel functions for: – Device allocation – Resource (e.g., memory) allocation – Scheduling
2. I/O System
2.1. Each I/O device consists of a device controller and the physical device itself.
2.2. Devices: - storage devices: for permanent storage (e.g. disk, tape) - communication devices: to transfer data from the computer to another machine (e.g. keyboard, a terminal display, or a serial port to a modem or a network).
2.3. Devices can be character-oriented or block-oriented
3. Optimizing Seek Time
3.1. • Multiprogramming on I/O-bound programs => set of processes waiting for disk
3.2. • Seek time dominates access time => minimize seek time across the set
4. Shortest-Seek-Time-First
4.1. Service request closest to read-write head
4.2. – Advantages • Higher throughput and lower response times than FCFS • Reasonable solution for batch processing systems
4.3. – Disadvantages • Does not ensure fairness • Possibility of indefinite postponement • High variance of response times • Response time generally unacceptable for interactive systems
5. I/O Strategies
5.1. • Direct I/O with polling – CPU is responsible to check I/O status
5.2. • DMA I/O with polling – rarely found (technology)
5.3. • Direct I/O with interrupts – transfer data in device (buffer). Interrupts happen on start and termination of data transfer – involve CU & go through CPU
5.4. • DMA I/O with interrupts – involve CU but not go through CPU – fastest.
6. Interrupt Driven I/O
6.1. • Instead of having the CPU continuously poll status register of I/O device(s), have I/O device notify CPUwhen it has completed an I/O operation.
6.1.1. – CPU initiates an I/O operation as described before
6.1.2. – as I/O device performs the operation, CPU is switched to another process (thru the process scheduler).
6.1.3. – When the I/O device is done, it notifies the CPU by sending it an interrupt signal.
6.1.4. – The CPU switches control to an interrupt handler to service the interrupt.
6.1.5. – The interrupt handler completes I/O operation and returns control to interrupted process.
7. Interrupt Handler
7.1. a program that is part of the device manager.
7.1.1. Save the state of the interrupted process: save the contents of CPU registers (all registers) and load CPU registers with its own values:
7.1.1.1. Context Switch -Determine which I/O device caused the interrupt -Branch to the device driver associated with that device.
8. Device Driver
8.1. a program that is part of the device manager.
8.1.1. When called, it does the following: – determine the cause of the interrupt – complete the I/O operation – clear the done flag of the device controller status register – restore the state of the interrupted process context switch – return control to interrupted process
9. Interrupt Vector
9.1. • Replace the InterruptRequest flag with an interrupt vector, ie. a collection of flags, one flag for each device. • Replace the OR gate with a vector of interrupt request lines one for each device. • An Interrupt Vector Table: a table of pointers to device drivers : entry i of the table stores the address of device driver i. • The interrupt vector table is generally stored at a fixed location in memory (e.g. first 100 locations).
10. First-Come-First-Served (FCFS) Disk Scheduling
10.1. Requests serviced in order of arrival
10.2. – Advantages • Fair • Prevents indefinite postponement • Low overhead
10.3. – Disadvantages • Potential for extremely low throughput – FCFS typically results in a random seek pattern because it does not reorder requests to reduce service delays
11. Race Condition
11.1. 1. Disable all other interrupts while an interrupt is being processed
11.2. 2. Enable other interrupts while an interrupt is being processed – Must use system stack to save PC and state of the interrupted process. – Must use a priority scheme. – Part of the interrupt handler routine should not be interrupted.
11.3. • Most CPUs have two types of interrupts: – maskable interrupts: can be interrupted – un-maskable interrupts: can not be interrupted
12. Why Disk Scheduling Is Necessary
12.1. • First-come-first-served (FCFS) scheduling has major drawbacks – Seeking to randomly distributed locations results in long waiting times – Under heavy loads, system can become overwhelmed
12.2. • Requests must be serviced in logical order to minimize delays – Service requests with least mechanical motion
12.3. • The first disk scheduling algorithms concentrated on minimizing seek times, the component of disk access that had the highest latency
12.4. • Modern systems perform rotational optimization as well
13. I/O Devices
13.1. hardware that connects the device to the computer’s address and data bus
13.2. – continuously monitors and controls the operation of the device. – provides an interface to the computer: a set of components that the CPU can manipulate to perform I/O operations. Need to have a standard interface so that devices can be nterchanged.
13.3. Device Manager: consists of a collection of device drivers
13.4. – hide the operation details of each device controller from application programmer. – provide a “common” interface to all sorts of devices.
14. Device Manager Abstraction
14.1. • Device have controllers that provide an interface to the software
14.2. A device driver is a collection of functions that abstract the operation of a particular device.
14.3. • The device manager infrastructure : part of the OS that houses the collection of device drivers
15. System Call Interface
15.1. • Functions available to application programs
15.2. • Abstract all devices (and files) to a few interfaces
15.3. • Make interfaces as similar as possible – Block vs character – Sequential vs direct access
15.4. • Device driver implements functions (one entry point per API function)
16. Device Status Table
16.1. a table containing information about each I/O device.
16.2. Contains an entry for each I/O device.
16.3. • Each entry contains such information as: – device type, address, state (idle, busy, not functioning, etc.) – if device is busy: • the type of operation being performed by that device • the process ID of the process that issued the operation • for some devices: a queue of waiting requests for that device
17. I/O Buffering
17.1. A buffer is a memory area used to store data while it is being transferred between two devices or between a device and an application.
17.2. Used to reduce the effects of speed mismatch between I/O device and CPU or among I/O devices.
17.3. • Generally used to allow more overlap between producer and consumer
17.4. ==> more overlap between the CPU and I/O devices.
18. LOOK & C-LOOK
18.1. LOOK: Improvement on SCAN scheduling
18.2. C-LOOK: Improves C-SCAN scheduling
19. Buffering
19.1. • A technique that people use in everyday life to help them do two or more things at the same time.
19.1.1. • Input buffering: technique of having the input device copy information into main memory before the process request it.
19.1.2. • Output buffering: technique of saving info in memory and then writing it to the device while the process continues execution.
19.2. • Employed by device manager to keep I/O devices busy during times when a process is not requiring I/O operations.
20. Disk Optimizations
20.1. • Transfer Time: Time to copy bits from disk surface to memory
20.2. • Disk latency time: Rotational delay waiting for proper sector to rotate under R/W head
20.3. • Disk seek time: Delay while R/W head moves to the destination track/cylinder
20.4. • Access Time = seek + latency + transfer
20.4.1. Characteristics of Moving-Head Disk Storage
20.4.1.1. • Physical layout of disk drives
20.4.1.2. • Rotate on spindle
20.4.1.3. • Made up of tracks, which in turn contain sectors
20.4.1.4. • Vertical sets of tracks form cylinders
20.4.1.5. – Rotational latency
20.4.1.6. – Seek time • Time for read-write head to move to new cylinder
20.4.1.7. – Transmission time • Time for all desired data to spin by read-write head