CST334 week 7 (31/100)
This week we discussed persistence and I/O. We reviewed the two types of i/o devices, block devices and stream devices. Block devices are like hard drives that have a fixed size of data that can be accessed randomly. Stream devices generate a stream of bytes that are not addressable; they come in a stream and are ephemeral. Each i/o device has its own hardware that is like a computer and has 3 registers. Status register is read to check the device state, command register to execute read, write or seek commands, and data register to actually transfer data. There are three ways to interact with devices: polling, interrupt-driven, and DMA. Polling put the cpu in a tight loop checking the status register and when the device is idle, executing a command and transferring data. It has the least latency. Interrupt driven uses less cpu because instead of a loop it puts the thread or process to sleep while waiting for the device. DMA uses special hardware to copy data from a device to a me...