Lecture 11 - Devices Flashcards
What is the difference between memory-mapped i/o and port-mapped i/o?
Memory mapped: mapped into memory and accessed using memory functions
Port-mapped: dedicated address space accessed using specialised processor instructions
How is I/O polling done?
CPU starts I/O then busy-waits for completion
Device has registers
For output, cpu writes data into data register, starts device write, busy-waits until status register indicates write is done
For input, cpu starts device reading, busy-waits until status register indicates read is done, then reads data in data register
How does Interrupt based I/O work?
CPU starts i/o device writing or reading
I/O device finishes writing/reading and sends interrupt to CPU
CPU jumps to correct handler which runs, then moves back to where it was when the interrupt occurred.
How does direct memory access I/O work?
Bypasses CPU to transfer data directly between I/O device and memory
Used to simplify/speed up large data movement
Makes CPU pause
REQUIRES DMA CONTROLLER
How do I/O channels work?
Device has specialised processor
CPU asks device to execute entire I/O program
What do device drivers do?
Go between device controllers and rest of OS
Communicate with controllers over bus
What do device controllers do?
Communicate with devices and, erm, control them
What is device independent I/O software?
Provides common library routines for things
e.g. buffering, error reporting, allocating and releasing dedicated devices
What sort of things might a device driver do?
Initialise devices
Interpret commands from OS
Manage data transfers
Accept and process interrupts
Report errors
e.g. init(), open(), close()
What is a block device?
Disk, cd-rom, tape..
transfers data in blocks of fixed or variable size
Usually used to store data, e.g. filesystem
What is a character device?
terminal, printer, keyboard, mice..
Transfer data a byte at a time
don’t store data
What is an example interface for a character device?
read(devicenumber, buffer, size)
write(devicenumber, buffer, size)
Example interface for block device
read(device, fromaddr, buffer)
write(device, toaddr, buffer)
seek(device, addr)
How does UNIX identify a device?
Major number - identifies device type
minor number - instance of a device type
e.g.
8,2 means:
8 - scsi disk driver
2 - a specific scsi disk
how does UNIX treat devices wrt the filesystem
Treats them as files so they show up under the filesystem with no content but metadata associated with it
located in /dev