Lecture Notes CS162 4/23/07 Taken by Jonathan Yu Remote procedure call - we'd like to make a "call" to a procedure on another machine + we'll call that a "remote procedure call" - a "remote" call can be to another process on a diff machine or on the same machine - issues: + how are arguments and results passed when there is no shared address space + in practice have you pass and return by value (as oppose to by pointer) - how is the callee located/identified? Static vs. dynamic Dynamic: operating system call -> finds where it is Static: when compiled somehow linked in - What happens if there are machine and/or communication failures? - Security - Overhead -> local call is one instruction, or 15 - 20, not much + Would like semantics to be same or similar to normal procedure call Mechanism Five components 1. caller(user) 2. user-stub - interface between the caller and the comm. Mach 3. communications package (RPCRuntime) 4. Server stub - interface b/t communication pacage and callee 5. callee Call steps: [caller] - use-stub (pack arguments) - RPCRuntime(transmit) call packet [RPCRUNTIME(receive) - server stub (unpack arguments) - calleee- server stub(packet results) - RPCRUNtime(transmit)] - result packet [RPCRUntime(receive - user-stub(unpack result) - caller] ------------------------------------------------------------------------------- TOPIC: virtual machines ------------------------------------------------------------------------------- - A virtual machine is a software supported caopy of the basic (hardware) machine + Usually accomplished by allowing most intrusctions to run on real hardware - Popular in the 70's -> went away, now back because of its useful facility -> Microsoft, apple - Virtual machine monitor (VMM) - piece of software that provides the pseudo- hardware machine? ___________________ | | | Bare Machine | | | v^v^v^v^v^v^v^v^v^v |v^v^v^v^v^v^v^v^v^v| | Privileged | | Software nucleus | |___________________| / \ / \ / extended \ / / nucleus \ \ / / \ \ ______/__/___ ___\__\_____ | | | | | user | extended | user | | program |----machine----| program | |_____________| interface |____________| - virtual machine run on base machines that are the same - emulators are used to provide dissimilar bare machine interface (i.e. different than the machine underneath) - contrasts with OS, which provide extended mach interfaces -> i.e. they are presumably better than the bare mach uses of virtual machine - high reliability due to high isolation between virtual machines - high security (you have copy of hardware, not actual hardware) - have students do system program example: vm370, m44/44x nowadays VMware (Mendel rosenblum) implementations - for performance reasons, run non-sensitive intstructions to actually execute on the bare hardware (don't want to simiulate hardware, want to use it much as possible) - trap and simulate all sensitive instructions - i.e. any which could affect the VMM or any of the other VMs + if it isn't possible to trap all sensitive instructions, then may not be possible to build VM on that machine - these copies are running OS, but they're going to run in user state, even though they think they're in supervisor state -> everytime they call something supervisor-like it's trapped - if you have 10 terabytes, and you want 10 copies, then each only get 1 terabyte, not 10 terabytes ___________________ | | | Bare Machine | | | v^v^v^v^v^v^v^v^v^v |v^v^v^v^v^v^v^v^v^v| | virtual | | machine monitor | |___________________| / \ / \ / virtual \ / / machine \ \ / / \ \ ______/__/___ ___\__\______ | | | | | privileged | basic | privileged | |software nucl|----machine----|software nucl| |_____________| interface |_____________| / \ / \ / \ / \ / \ / \ / \ ... / \ ______/______ ______\_____ | | | | | user | extended | user | | program |--machine--| program | |_____________| interface |____________| _____________________ | | | User VM |-----------------. |_____________________|------------. | | | | ______________v______________ | | | OS(mapping) | | | |_____________________________| PT1| | | | | __________v__________ | | | |<-----------' | | VM | |PT3 |_____________________|------------. | | | | ______________v______________ | | | VMM (mapping) | | | |_____________________________| PT2| | | | | __________v__________ | | | |<-----------' | | Real Memory |<----------------' |_____________________| - sounds good, but there is a catch: + ignoring virtual part map from user to real machine in a page table (PT),and a tlb that caches that translation (see diagram) + if tlb caches PT2, how does PT2 get translated? + if tlb caches PT1, how does PT2 get translated? Cache both - compose the mappings, want a map from user VM to RM build PT3, which is a composition of PT1 and PT2 (like functions f2(f1(vm))-> rm + what happens when there's a pagefault? (not in PT3) -> means it's not in PT1, or PT2, or both -> have to trap somewhere VMM (the only one in supervisor state, everyone else user state), figures out who caused it if PT1 caused it, then passes the trap to OS, who fixed PT1, and update PT3 -> so the way to do this would be to trap to VMM somehow -> by purging TLB or purging TLB entry? (as long as it's a supervisor state instruction) if PT2 caused it, then VMM fixes it and fixes PT3 I/O - it is necessary to trap and simulate I/O + want to permit i/o only to valid areas for the VM + without interfering with other VMs + the i/o code (e.g. channel programs) must be properly interpreted or translated, since they use real addressess (for this reason, self modifying channel program are usually prohibited, as they aretoo difficult to translate) - i/o devices are usually simulated. Each use is given virtual io devices ("mini-disks"), which look like real hardware devices - the VMM keeps a bit fo each VM which specifies whether the VM is in user state or supervisor state. It can provide appropriate simulation of sensitive instructions' attemps to execute sensitive instructions to user state cases. In supervisor state, they are executed appropriately hardware virtualizer - idea is to have hardware which dynamically maps N levels of vm into the hardware vm performances - will run slower than real machine due to simulation of sensitive instructions - specific performance degrdations + support of private instructions + maintain the state of the virtual processor + support paging with virtual machine + console function - each machine thinks it has the monitor and output acceptance and reflection of interrupts to individual vms translation of channel programs maintenance of clocks ways to enhance performance: - dedicate some resources so they don't have to be mapped or simulated - give certain critical vms priority to run - run virtual = real (same as #1) - let vm instead of OS do paging (if PS does it, it gets done twice) - modify OS to avoid costly(slow) features - extend VMM to provide performance enhancements (but not truly a VM anymore. (e.g vm assit on 370) - extend hardware to support VM special performance problems: - optimization within the OS may conflict with optimization within VMM. (E.g. double paging anomally. Buffer paging problem of IMs, disk optimimal where disk is mapped, spooling by VMM and also by OS)