Chapter 5: Input/Output - block devices x character devices; - when a read is executed in a disk, for example, what comes out is a serial bit stream, starting with a preamble, then the 4096 bits in a sector, and finally a checksum; - the CPU may communicate with the device control registers in two ways: using I/O ports (8- or 16-bit integers) or memory-mapped I/O; - when I/O ports are used, the ASs for memory and I/O are different; - the good thing about MMIO is that it can be accessed as any other memory location. The bad side is that other parts of the system (e.g. caches) need to theat this address range differently (e.g., port values cannot be cached!); - in the pentium, the PCI bridge chip holds an address interval that indicates when the PCI bus needs to server the addr request, instead of the memory bus. This interval is set up during boot time; - to avoid having the CPU ask for each word in an I/O transfer, DMA is used; - the OS can use DMA only if the device has a DMA controller; sometimes a single DMA controller is present in the motherboard; - when an interrupt occurs, the controller saves a number on the address lines, to indicate which device wants attention. This number is used to index the interrupt vector, to get a new program counter (the one of the corresponding handler); - precise interrupt: - PC is saved in a known place; - instructions before PC have fully executed; - no instruction after PC has executed; - the execution state of the instruction pointed by the PC is known; - slow interrupts (imprecise) are sometimes a problem for superscalar CPUs (they save too much information in the stack for the OS to analyze); - programmed I/O: CPU does all the work. After outputing a character to a printer, the CPU does polling (busy waiting). the other possibilities are interrupt driven I/O and DMA; - disk access time: seek time + rotational delay + data transfer time; - disk scheduling algorithms: FCFS, SSF (shortest seek first), elevator (SCAN), CSCAN (like the elevator, but goes in only one direction);