Prashanth L.A.
2023-11-06
How should I/O be integrated into systems?
What are the general mechanisms?
How can we make the efficiently?
CPU is attached to the main memory of the system via some kind of memory bus
Some devices are connected to the system via a general I/O bus
Register | Description |
---|---|
Status register | See the current status of the device |
Command register | Tell the device to perform a certain task |
Data register | Pass data to the device or get data from the device |
while STATUS == BUSY
; //wait until device is not busy
write data to data register
write command to command register
(Doing so starts the device and executes the command)
while STATUS == BUSY
; //wait until device is done with your request
Plus | Minus |
---|---|
Simple, works. | Wastes CPU time |
How to avoid the costs of polling?
How can the OS check device status without frequent polling, and thus lower the CPU overhead required to manage the device?
Plus | Minus |
---|---|
CPU used better | Not good for fast devices |
What is PIO?
With PIO, the CPU spends too much time moving data to and from devices by hand. How can we offload this work and thus allow the CPU
to be more effectively utilized?
When completed DMA raises an interrupt I/O begins on Disk
Polling
Intterupt
CPU copies data from memory to device
DMA
How should the HW communicate with a device?
Should there be explicit instructions?
Or are there other ways to do it?
How to build a device-neutral OS
How can we keep most of the OS device-neutral, thus hiding the details of device interactions from major OS subsystems?
According to cloc run against 3.13, Linux is about 12 million lines of code.
Ref: https://unix.stackexchange.com/questions/223746/why-is-the-linux-kernel-15-million-lines-of-code
Problems with top 2 million?