CSE 120 Lecture Notes - Lecture 14: Protected Mode, Linked List, Hash Table
33 views6 pages
-devices communicate over an “I/O” bus
Problems: so many different types of I/O devices!
- Wide range: speed, operation, data transfer units, etc.
- Have to take into account NEW devices with new functionality?
- How does a process “initiate” I/O?
- How is synchronization achieved?
- How is data transferred?
Background: I/O Hardware
CPU and device (controller) communicate via
- I/O instructions - instruction of the ISA designed specifically for I/O
- Memory instructions (“memory-mapped”) - loads/stores
- Programmed I/O - CPU is involved in moving data from CPU register TO device or vice
- DMA (Direct Memory Address) - CPU “tells” device to move x amount of data to a certain
- Initiates process, and then you take over from there
- Polling - checking a register, bit, memory, if device is “ready”, and “busy-waits” otherwise
- Interrupts - CPU does not “explicitly” check the device
- Device generates an interrupt for which the CPU then handles it
Buffered and Unbuffered I/O
Buffer - “temporary” holding place for data
Unbuffered - NO temporary holding place!
When is it good to have buffers?
-data copied from device INTO a buffer
-goes through process
-process itself might have data copied into the kernel into the buffer
-then goes out to the other device
-writing from process goes DIRECTLY to the device!
Pros and Cons of buffering
- You can hold the data for the device in the kernel while waiting for “pages” of the
process to show
- A process can write into buffer and can then go and do its own thing!
- Kernel buffering is expensive (copying memory is expensive)
- Consider effect on caches - hardware caches are filled
- The more you copy data, the more you “exercise” the caches, which can blow
away a lot of needed data!
Dealing w/ Complexity of Devices
- Variable vs fixed-size units
- Sequential vs “random” access
- Sync vs async
- Speed of operation
I/O System - part of the system devoted to I/O
-software that deals w/ I/O
-”mostly” in the kernel
-also in processes (in form of library, stdio for example)
I/O System Structure: Layered
User User I/O (stdio)
Kernel Device-Independent I/O, Device drivers
Hardware Devices and Device controllers
Device Dependent: Device Drivers
-encapsulates “device-dependent” code
-in order for it to interact w/ other parts of the kernel, it implements a standard interface
-open(), close(), read(), write()
-Kernel calls on these functions!
-interrupt handlers (at least 1)
- executes when I/O completes
- updates data structures
- wakes up waiting processes
- knows how to generate a read in disk memory