231 Fall 2008 -- Exam 5 (with answers) No calculators. Circle one of (a or b) and one of (x or y) for each question 1-3. a. CPU transfers bytes between memory and device during I/O b. device controller transfers bytes between memory and device during I/O x. CPU is dedicated to I/O transfer and busy waits for device to be ready y. CPU turns attention to I/O transfer upon interrupt but otherwise can switch to other tasks 1. programmed I/O Circle: a Also Circle: x 2. interrupt-driven I/O Circle: a Also Circle: y 3. DMA Circle: b Also Circle: y Matching. Select the best answer. 4. __d__ disk seek a. time until disk head crash b. time for controller connect overhead 5. __e__ disk rotational delay c. time to read/write the disk sector(s) containing the physical record 6. __c__ disk transfer d. time to move the read/write heads to a track e. time for the needed sector to rotate under 7. __g__ isolated I/O the read/write head f. device registers are accessed using regular 8. __f__ memory-mapped I/O load and store instructions g. device registers are accessed using special 9. __i__ logical record input and output instructions h. device registers are subset of CPU registers 10. _k__ physical record i. unit of data transfer for an application j. unit of data transfer for a load or store 11. _l__ blocking instruction k. unit of data transfer for an I/O device l. multiple logical records per physical record m. multiple physical records per logical record 12. List the three device registers found in a simple I/O controller. (1) data (or buffer) (2) command (3) status 13. List the two additional device registers found in a DMA I/O controller. (4) address (5) count 14. Draw a diagram of the fetch/decode/execute cycle of a computer that includes the four actions that occur when interrupts are accepted and the actions for an RTI instruction. +-------+ .----->| fetch | | +-------+ | v | .------. | < decode > | `------' | | | +--+---------+------------+------- ... ------------+ | v v v v | +---------+ +---------+ +---------+ +-----------------------+ | | execute | | execute | | execute | ... | return from interrupt | | | load | | add | | store | | (restore PC and PSR) | | +---------+ +---------+ +---------+ +-----------------------+ | v v v v | +--+---------+------------+------- ... ------------+ | | | .-------------------------------------------------. | < if interrupt requested and interrupts are enabled > | no `-------------------------------------------------' +<--------' | yes ^ v | +--------------------------------------------------+ | | 1) save PC and PSR | | | 2) switch execution mode to kernel (OS-only) | | | 3) disable/restrict further interrupts | | | 4) load new PC from IVT (interrupt vector table) | | +--------------------------------------------------+ | | `--------------' 15. What does the acronym RAID stand for? Explain in general how a RAID system can tolerate the failure of a single disk. RAID = redundant array of independent disks (or inexpensive disks) redundancy is provided in one of several ways (e.g., parity bits, mirrored disks). if one disk fails, the information can be restored (e.g., reconstructed from the parity bits or found on a mirror disk) 16. Consider a disk with 2 millisecond average seek time, 2 millisecond average rotational latency, and a data transfer rate of 2000 KB/sec. Consider also the transfer of unrelated blocks of 2 KB each (that is, use average seek and rotational latency). What is the average number of such blocks transferred per second? pe ms seek + 2 ms rot. latency + 2KB / 2000KB/s transfer time = 2 + 2 + 1 ms = 5 ms 5 ms / block => take reciprocal => 1 block / 5 ms = 200 blocks/sec 17. Consider the same disk as above but now consider the transfer of six contiguous blocks at a time. That is, the data transfer is 12 KB (= 6 * 2 KB each), but there is only a single seek and a single wait for rotational positioning for the complete transfer. What is the average number of 2KB blocks transferred per second? 2 ms seek + 2 ms rot. latency + 12KB / 2000KB/s transfer time = 2 + 2 + 6 ms = 10 ms 5 ms / 6 blocks => reciprocal => 6 blocks / 10 ms = 600 blocks/sec 18. We found that the I/O functions we use in our program are typically implemented as a series of wrappers around an underlying invocation of the operating system. E.g., scanf(...) // stdin already open user program statement +-----------------------------------------+ v | fscanf( stdin, ... ) | buffered formatted read | +------------------------------------+ | v | | read( fd, buffer, BUFFER_LENGTH ) | | low-level read | | +------------------------+ | | | | | | mov %fd_r,%o0 | | | | | | | set buffer,%o1 | | | | | | | mov BUFFER_LENGTH,%o2 | | | | | | | mov READ,%g1 | | | v | | | ta 0 | | | trap to OS | | +------------------------+ | | | +------------------------------------+ | +-----------------------------------------+ Explain why a user program is not allowed to directly access an I/O device. I/O devices are shared and must be protected from buggy or malicious user programs. so direct user access is not allowed, and a user must request the OS to perform the I/O action on behalf of the user. (the OS is responsible for checking that the requested action is permissible before performing the action.) XC. Fill in the blanks with "j" or "k", as appropriate, for this double- buffering logic. j = 1; k = 2; read data into buffer _j__ for( i = 1; i < N; i++ ){ read data into buffer _k__ process data in buffer _j__ swap(_j__,_k__) } process data in buffer _j__