P3L5. I/O Management Flashcards
What is an I/O device? Examples?
A device specifically responsible for providing inputs or directing outputs.
Keyboard
Display
Microphone
Speakers
Mouse
Network Interface Card Disk
What are basic I/O device features?
Control registers
Can be accessed by the CPU and permit CPU/device interactions. Divided into:
- command registers: used by the CPU to control what the device will do
- data registers: used by the CPU to control data transfers in/out of the device
- status registers: used by the CPU to find out what’s happening on the device
Microcontroller
The device’s CPU
On Device Memory
Other Logic
What’s a device driver?
A device-specific software component. The OS has to include a device driver for every device type in the system.
Device drivers are responsible for access, management, and control.
What are the types of devices? What do they do?
Block: disk
- read/write blocks of data
- direct access to arbitrary block
Character: keyboard
- get/put character
Network devices
How does the OS represent a device?
As a special device file.
In Unix-like systems all devices appear as files under /dev in a special file system (e.g., tmpfs, devfs)
What is memory-mapped I/O?
Device registers appear to the CPU as memory locations at a specific physical address.
When the CPU writes to these locations, the integrated memory PCI controller routes the write to the correct device.
This means that a portion of physical memory is dedicated for interactions with the device.
The portion of memory reserved for I/O interactions is controlled by Base Address Registers (BAR)
What is I/O port?
- dedicated in/out instructions for device access
- target device (I/O port) and value in register
How can the CPU learn of a device’s status?
Interrupt: device can generate interrupts to the CPU
- interrupt handling steps
+ can be generated as soon as possible
Polling: CPU can poll device by reading its status register
+ when convenient for OS
- delay or CPU overhead
Programmed I/O (PIO) vs Direct Memory Access (DMA)?
A system can request an operation from a device using programmed I/O or Direct Memory Access (DMA)
Programmed I/O (PIO)
- no additional hardware support
- CPU “programs” the device via command registers and data registers
- requires many store instructions by CPU
- better for small transfers
Direct Memory Access (DMA)
- relies on special hardware support: DMA controller
- CPU “programs” the device via command registers and DMA controls
- requires 1 store operation by CPU
- data buffer must be in physical memory until transfer completes. thus, memory regions involved in the transfer are pinned (non-swappable)
- better for large transfers
What is OS bypass?
Access to a device doesn’t have to go through the kernel. This is called OS bypass.
- device registers/data directly accessible
- OS configured, then gets out of the way
- requires “user-level driver”
- OS retains coarse-grain control
- OS relies on device features
- sufficient registers so some can be devoted to the user process but some can still remain for the kernel for course-grain control
- demux capability to correctly pass data arriving at the device to the correct process
What happens to a calling thread when an I/O request is made?
Synchronous I/O operations
- process blocks
Asynchronous I/O operations
- process continues
Later…
- process checks and retreives results
- OR the process is notified the operation completed and results are ready
What is the block device stack?
What is a virtual file system?
A virtual file system layer hides from applications all details about the underlying file system.
Applications interact with the virtual file system using the same API (e.g., POSIX API). The virtual file system specifies a more details API that each of the underlying file system must implement.
What a some virtual file system abstractions?
file: elements on which the VFS operations
file descriptor: OS representation of file
- supported operations: open, read, write, sendfile, lock, close
inode: persistent data structure, representation of file “index”. this index is important b/c file does not need to be stored contiguously on disk.
- list of all data blocks
- device, permissions, size
dentry: directory entry, corresponds to single patch component
- /users/ada => /, /users, /users/ada
- file system maintains a dentry cache
superblock: filesystem-specific information regarding the FS layout
What does the virtual file system look like on disk?
file: data blocks on disk (non-contiguous)
inode: tracks files’ blocks. also resides on disk in some block (contiguous)
superblock: overall map of disk blocks
- inode blocks
- data blocks
- free blocks