DOC PREVIEW
Berkeley COMPSCI 61C - Lecture Notes

This preview shows page 1 out of 4 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS61C L37 I/O (1) Garcia, Fall 2004 © U CBLecturer PSOE Dan Garciawww.cs.berkeley.edu/~ddgarciainst.eecs.berkeley.edu/~cs61cCS61C : Machine StructuresLecture 37 Input / OutputUK researchers have found alink between the distractions of work-related email usage and lower IQ scores.The IQ drops were up to 10 points, whichcompares to only 4 points from weed!Email “poses threat to IQ”?! ⇒www.cnn.com/2005/WORLD/europe/04/22/text.iq/CS61C L37 I/O (2) Garcia, Fall 2004 © U CBReview• Virtual memory to Physical MemoryTranslation too slow?• Add a cache of Virtual to PhysicalAddress Translations, called a TLB• Spatial Locality means Working Set ofPages is all that must be in memory forprocess to run fairly well• Virtual Memory allows protectedsharing of memory between processeswith less swapping to diskCS61C L37 I/O (3) Garcia, Fall 2004 © U CBRecall : 5 components of any Computer Processor (active)ComputerControl(“brain”)Datapath(“brawn”)Memory(passive)(where programs, data live whenrunning)DevicesInputOutputKeyboard, MouseDisplay, PrinterDisk,NetworkEarlier Lectures Current LecturesCS61C L37 I/O (4) Garcia, Fall 2004 © U CBMotivation for Input/Output• I/O is how humans interact withcomputers• I/O gives computers long-term memory.• I/O lets computers do amazing things:• Read pressure of synthetic hand andcontrol synthetic arm and hand of fireman• Control propellers, fins, communicatein BOB (Breathable Observable Bubble)• Computer without I/O like a car withoutwheels; great technology, but won’t getyou anywhereCS61C L37 I/O (5) Garcia, Fall 2004 © U CBI/O Device Examples and Speeds• I/O Speed: bytes transferred per second(from mouse to Gigabit LAN: 10-million-to-1)• Device Behavior Partner Data Rate (KBytes/s)Keyboard Input Human 0.01Mouse Input Human 0.02Voice output Output Human 5.00Floppy disk Storage Machine 50.00Laser Printer Output Human 100.00Magnetic Disk Storage Machine 10,000.00Wireless Network I or O Machine 10,000.00Graphics Display Output Human 30,000.00Wired LAN Network I or O Machine 125,000.00When discussing transfer rates, use 10xCS61C L37 I/O (6) Garcia, Fall 2004 © U CBWhat do we need to make I/O work?• A way to present themto user programs sothey are usefulcmd reg.data reg.Operating SystemAPIsFilesProcMem• A way to connect manytypes of devices to theProc-MemPCI BusSCSI Bus• A way to control thesedevices, respond tothem, and transfer dataCS61C L37 I/O (7) Garcia, Fall 2004 © U CBInstruction Set Architecture for I/O• What must the processor do for I/O?• Input: reads a sequence of bytes• Output: writes a sequence of bytes• Some processors have special inputand output instructions• Alternative model (used by MIPS):• Use loads for input, stores for output• Called “Memory Mapped Input/Output”• A portion of the address space dedicatedto communication paths to Input or Outputdevices (no memory there)CS61C L37 I/O (8) Garcia, Fall 2004 © U CBMemory Mapped I/O• Certain addresses are not regularmemory• Instead, they correspond to registersin I/O devicescntrl reg.data reg.00xFFFFFFFF0xFFFF0000addressCS61C L37 I/O (9) Garcia, Fall 2004 © U CBProcessor-I/O Speed Mismatch• 1GHz microprocessor can execute 1billion load or store instructions persecond, or 4,000,000 KB/s data rate• I/O devices data rates range from 0.01KB/s to 125,000 KB/s• Input: device may not be ready to senddata as fast as the processor loads it• Also, might be waiting for human to act• Output: device not be ready to acceptdata as fast as processor stores it• What to do?CS61C L37 I/O (10) Garcia, Fall 2004 © U CBProcessor Checks Status before Acting• Path to device generally has 2 registers:• Control Register, says it’s OK to read/write(I/O ready) [think of a flagman on a road]• Data Register, contains data• Processor reads from Control Registerin loop, waiting for device to set Readybit in Control reg (0 ⇒ 1) to say its OK• Processor then loads from (input) orwrites to (output) data register• Load from or Store into Data Registerresets Ready bit (1 ⇒ 0) of ControlRegisterCS61C L37 I/O (11) Garcia, Fall 2004 © U CBSPIM I/O Simulation• SPIM simulates 1 I/O device: memory-mapped terminal (keyboard + display)• Read from keyboard (receiver); 2 device regs• Writes to terminal (transmitter); 2 device regsReceived ByteReceiver Data0xffff0004Unused (00...00)(IE)Receiver Control0xffff0000Ready(I.E.)Unused (00...00)TransmittedByteTransmitter Control0xffff0008Transmitter Data0xffff000cReady(I.E.)Unused (00...00)UnusedCS61C L37 I/O (12) Garcia, Fall 2004 © U CBSPIM I/O• Control register rightmost bit (0): Ready• Receiver: Ready==1 means character in DataRegister not yet been read;1 ⇒ 0 when data is read from Data Reg• Transmitter: Ready==1 means transmitter isready to accept a new character;0 ⇒ Transmitter still busy writing last char- I.E. bit discussed later• Data register rightmost byte has data• Receiver: last char from keyboard; rest = 0• Transmitter: when write rightmost byte,writes char to displayCS61C L37 I/O (13) Garcia, Fall 2004 © U CBI/O Example• Input: Read from keyboard into $v0lui $t0, 0xffff #ffff0000Waitloop: lw $t1, 0($t0) #controlandi $t1,$t1,0x1beq $t1,$zero, Waitlooplw $v0, 4($t0) #data• Output: Write to display from $a0lui $t0, 0xffff #ffff0000Waitloop: lw $t1, 8($t0) #controlandi $t1,$t1,0x1beq $t1,$zero, Waitloopsw $a0, 12($t0) #data• Processor waiting for I/O called “Polling”• “Ready” bit from processor’s point of view!CS61C L37 I/O (15) Garcia, Fall 2004 © U CBCost of Polling?• Assume for a processor with a 1GHzclock it takes 400 clock cycles for apolling operation (call polling routine,accessing the device, and returning).Determine % of processor time for polling• Mouse: polled 30 times/sec so as not tomiss user movement• Floppy disk: transfers data in 2-Byte unitsand has a data rate of 50 KB/second.No data transfer can be missed.• Hard disk: transfers data in 16-Byte chunksand can transfer at 16 MB/second. Again, notransfer can be missed.CS61C L37 I/O (16) Garcia, Fall 2004 © U CB% Processor time to poll [p. 677 in book]Mouse Polling, Clocks/sec= 30 [polls/s] * 400 [clocks/poll] = 12K [clocks/s]• % Processor for polling:12*103 [clocks/s] / 1*109 [clocks/s] = 0.0012%⇒ Polling mouse little impact on processorFrequency of Polling Floppy= 50 [KB/s] / 2 [B/poll] = 25K [polls/s]• Floppy Polling,


View Full Document

Berkeley COMPSCI 61C - Lecture Notes

Documents in this Course
SIMD II

SIMD II

8 pages

Midterm

Midterm

7 pages

Lecture 7

Lecture 7

31 pages

Caches

Caches

7 pages

Lecture 9

Lecture 9

24 pages

Lecture 1

Lecture 1

28 pages

Lecture 2

Lecture 2

25 pages

VM II

VM II

4 pages

Midterm

Midterm

10 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?