




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





















Lec 10
Systems Architecture II
Jeremy R. Johnson Anatole D. Ruslanov
William M. Mongan
*This lecture was derived from material in the text (Secs. 8.5-8.7). Some or all figures from Computer Organization and Design: The Hardware/SoftwareApproach, Third Edition, by David Patterson and John Hennes
s
y, are copyrighted
material (COPYRIGHT 2004 MORGAN KAUFMANN PUBLISHERS, INC. ALL RIGHTSRESERVED).
Contributions from Mary Jane Irwin (
www.cse.psu.edu/~mji
)
Lec 10
Systems Architecture II
How is a user I/O request transformed into a device command andcommunicated to the device?
How is data actually transferred to or from a memory location?
What is the role of the operating system?
Role of the OS
Giving commands to the I/O system
I/O commands
Memory mapped I/O
Communicating with the processor
polling
interrupts
Transferring data between a device and memory
Direct Memory Access (DMA)
Designing an I/O system
Lec 10
Systems Architecture II
To protect the shared I/O resources, the user program is not allowed tocommunicate directly with the I/O device
I/O interrupts result in a transfer of processor control to the supervisor(OS) process
Lec 10
Systems Architecture II
Lec 10
Systems Architecture II
command and device number specified in the instruction
processor communicates the device address via a set of wiresincluded as part of the I/O bus
illegal to execute while in user mode
Portions of the address space are assigned to I/O devices
commands and data are written to special addresses
data and status info read from special addresses
Memory system ignores operation (determined by address)
I/O controller, sees the operation, and transmits it to the device
Lec 10
Systems Architecture II
Special I/O instructions
Must specify both the device and the command
Memory-mapped I/O
Portions of the high-order memory address space are assigned to each I/Odevice
Read and writes to those memory addresses are interpreted as commands to the I/O devices
Load/stores to the I/O address space can only be done by the OS
Polling – the processor periodically checks the status of an I/O device todetermine its need for service
Processor is totally in control – but does all the work
Can waste a lot of processor time due to speed differences
Interrupt-driven I/O – the I/O device issues an interrupts to the processorto indicate that it needs attention
Lec 10
Systems Architecture II
Assume 400 cycles for polling operation and a 500 MHz clock
Determine fraction of CPU time consumed in the following 3 cases(assume that you poll often enough so that no data is lost and that thedevices are potentially always busy)
Mouse must be polled 30 times per second
Floppy disk transfers data to processor in 16-bit units and has atransfer rate of 50 KB/sec
Hard disk drive transfers data in 4 word chunks and can transfer at4 MB/sec
Lec 10
Systems Architecture II
400 = 12,000 cycles per second for polling
Fraction of processor clock cycles = (
3
6
400 cycles per second for polling
Fraction of processor clock cycles = (
6
6
400 cycles per second for polling
Fraction of processor clock cycles = (
6
6
sec /
accesses
access
polling /
bytes 2
sec /
sec /
accesses
access
polling /
bytes
sec /
Lec 10
Systems Architecture II
Lec 10
Systems Architecture II
Lec 10
Systems Architecture II
Is not associated with any instruction so doesn’t prevent any instructionfrom completing
You can pick your own convenient point to handle the interrupt
Need a way to identify the device generating the interrupt
Can have different urgencies (so may need to be prioritized)
Relieves the processor from having to continuously poll for an I/O event;user program progress is only suspended during the actual transfer of I/Odata to/from user memory space
Cause an interrupt (I/O device) and detect an interrupt and save thenecessary information to resume normal processing after servicing theinterrupt (processor)
Lec 10
Systems Architecture II
500 MHz clock
Overhead of transfer including interrupt is 500 cycles
Hard drive is transferring data only 5% of the time
6
cycles per second for disk
Fraction of processor clock cycles = (
6
6
Fraction of processor clock cycles = 25%
Compare to polling - the absence of overhead when the disk is notactive is the major advantage of an interrupt-driven interface
Lec 10
Systems Architecture II
500 MHz clock
Assume transfer with DMA and initial DMA setup takes 1000 cycles
Overhead of interrupt at completion is 500 cycles
If the average transfer is 8KB, what fraction of the CPU is consumed ifthe disk is active 100% of the time (ignore processor/DMA controllerbus contention)
Cycles/sec for disk =
Fraction of processor clock cycles = (
3
6
sec
sec /
3 −
sec /
cycles
clock
transfer /
sec
transfer
500cycles/
3
3
−
Lec 10
Systems Architecture II
Should physical or virtual addresses be used?
If virtual, the DMA unit must translate to physical addresses.
If physical must ensure that addresses don’t cross page boundaries(otherwise memory addresses would not be contiguous)
Can break transfer into a sequence of page size transfers
OS must not remap memory during DMA transfer
The value of a memory location as seen by DMA and the processormay differ
Stale data or coherency problem (value in cache different frommemory). Solved by routing through cache or cache flushing