DOC PREVIEW
CMU CS 15410 - Hardware Overview

This preview shows page 1-2-3-25-26-27 out of 27 pages.

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

Unformatted text preview:

15-410, S’04- 1 -Hardware OverviewJan. 19, 2004Dave EckhardtDave EckhardtBruce MaggsBruce MaggsL04_Hardware15-410“Dude, what were you thinking?”15-410, S’04- 2 -SynchronizationToday's classToday's classNot exactly Chapter 2 or 13WednesdayWednesdayProject 0 is dueLecture on “The Process”15-410, S’04- 3 -OutlineComputer hardwareComputer hardwareCPU StateCPU StateFairy tales about system callsFairy tales about system callsCPU context switch (intro)CPU context switch (intro)Interrupt handlersInterrupt handlersInterrupt maskingInterrupt masking15-410, S’04- 4 -Inside The Box - Historical/LogicalCPUMemoryGraphicsEthernetIDEFloppyUSB15-410, S’04- 5 -Inside The Box - ReallyCPUMemoryAGP GraphicsIDEFloppyUSBNorth BridgeSouth BridgePCIEthernetSCSI15-410, S’04- 6 -CPU StateUser registers (on Planet Intel)User registers (on Planet Intel)General purpose - %eax, %ebx, %ecx, %edxStack Pointer - %espFrame Pointer - %ebpMysterious String Registers - %esi, %edi15-410, S’04- 7 -CPU StateNon-userNon-user registers, a.k.a.... registers, a.k.a....Processor status register(s)Processor status register(s)User process / Kernel processInterrupts on / offVirtual memory on / offMemory modelsmall, medium, large, purple, dinosaur15-410, S’04- 8 -CPU StateFloating Point Number registersFloating Point Number registersLogically part of “User registers”Sometimes special insteadSome machines don't have floating pointSome processes don't use floating point15-410, S’04- 9 -Story time!Time for some fairy talesTime for some fairy talesThe getpid() story (shortest legal fairy tale)The read() story (toddler version)The read() story (grade-school version)15-410, S’04- 10 -The Story of getpid()User process is computingUser process is computingUser process calls getpid() library routineLibrary routine executes TRAP(314159)The world changesThe world changesSome registers dumped into memory somewhereSome registers loaded from memory somewhereThe processor has The processor has entered kernel modeentered kernel mode15-410, S’04- 11 -User ModeOperatingSystemProcess 1Process 2CPU15-410, S’04- 12 -Entering Kernel ModeOperatingSystemProcess 1Process 2CPU15-410, S’04- 13 -Entering Kernel ModeOperatingSystemProcess 1Process 2CPUEthernetIDEFloppyUSB15-410, S’04- 14 -The Kernel Runtime EnvironmentLanguage runtimes differLanguage runtimes differML: no stack, “nothing but heap”C: stack-basedProcessor is mostly agnosticProcessor is mostly agnosticTrap handler builds kernel runtime environmentTrap handler builds kernel runtime environmentSwitches to correct stackTurns on virtual memoryFlushes caches15-410, S’04- 15 -The Story of getpid()Process in kernel modeProcess in kernel moderunning->u_reg[R_EAX] = running->u_pid;Return from interruptReturn from interruptProcessor state restored to user mode(modulo %eax)User process returns to computingUser process returns to computingLibrary routine returns %eax as value of getpid()15-410, S’04- 16 -Returning to User ModeOperatingSystemProcess 1Process 2CPU15-410, S’04- 17 -A Story About read()User process is computingUser process is computing•count = read(0, buf, sizeof (buf));User process “goes to sleep”User process “goes to sleep”Operating system issues disk readOperating system issues disk readTime passesTime passesOperating system copies dataOperating system copies dataUser process wakes upUser process wakes up15-410, S’04- 18 -Another Story About read()P1: read()P1: read() Trap to kernel modeKernel: issue disk readKernel: issue disk readKernel: switch to P2Kernel: switch to P2 Return from interrupt - but to P2, not P1!P2: compute 1/3 of Mandelbrot setP2: compute 1/3 of Mandelbrot set15-410, S’04- 19 -Another Story About read()Disk: done!Disk: done! Interrupt to kernel modeKernel: switch to P1Kernel: switch to P1 Return from interrupt - but to P1, not P2!15-410, S’04- 20 -Interrupt Vector TableHow does CPU handle How does CPU handle thisthis interrupt? interrupt? Disk interrupt -> disk driver Mouse interrupt -> mouse driverNeed to knowNeed to know Where to dump registersoften: property of current process, not of interrupt New register values to load into CPUkey: new program counter, new status register15-410, S’04- 21 -IA32 Single-Task Mode Example•Interrupt/Exception while in kernel mode (Project 1)Interrupt/Exception while in kernel mode (Project 1)•Hardware pushes registers on current stack, NO STACK CHANGEHardware pushes registers on current stack, NO STACK CHANGE1. EFLAGS (processor state)2.CS/EIP (return address)3. Error code (if interrupted exception procedure wants to)From intel-sys.pdf15-410, S’04- 22 -Interrupt Vector TableTable lookupTable lookup Interrupt controller says: this is interrupt source #3CPU knows table base pointer, table entry sizeCPU knows table base pointer, table entry sizeSpew, slurp, off we goSpew, slurp, off we go15-410, S’04- 23 -Race Conditionsif (device_idle) start_device(request);else enqueue(request);15-410, S’04- 24 -Race ConditionsaaaaaaUser process Interrupthandlerif(device_idle)INTERRUPT...device_idle= 1;RETURN FROMINTERRUPTenqueue(request)15-410, S’04- 25 -Interrupt maskingAtomic actionsAtomic actions Block device interrupt while checking and enqueueing Or use a lock-free data structure[left as an exercise for the reader]Avoid blocking Avoid blocking allall interrupts interrupts [not a big issue for 15-410]Avoid blocking too longAvoid blocking too long Part of Project 3 grading criteria15-410, S’04- 26 -Timer – BehaviorCount somethingCount somethingCPU cycles, bus cycles, microsecondsWhen you hit a limit, generate an interruptWhen you hit a limit, generate an interruptReload counter (don't wait for software to do it)Reload counter (don't wait for software to do it)15-410, S’04- 27 -Timer – Why?Why interrupt a perfectly good execution?Why interrupt a perfectly good execution?Avoid CPU hogsAvoid CPU hogs for (;;) ;Maintain accurate time of dayMaintain accurate time of dayBattery-backed calendar counts only seconds (poorly)Dual-purpose interruptDual-purpose interrupt++ticks_since_boot;force process switch


View Full Document

CMU CS 15410 - Hardware Overview

Download Hardware Overview
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 Hardware Overview 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 Hardware Overview 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?