Material Type: Notes;
Professor: Kulkarni;
Class: Special Topics: Advanced Database Systems;
Subject: Elect Engr & Computer Science;
University: University of Kansas;
Term: Spring 2009;
Download Process Virtual Mechanics - Outline | EECS 700 and more Study notes Deductive Database Systems in PDF only on Docsity!
Process Virtual Machines – Outline
Structure of a process VM
Compatibility issues
Guest-to-host state mapping issues
Emulation of
memory, instructions, exceptions, and OS calls
Profiling
Optimization issues
Background
Compiled applications are bound by the ABI to only work for one OS-ISA pair - process VMs overcome this limitation
Example: IA-32 EL process VM with interfaces for Windows and Linux HOST OS Disk file sharing guest process create host process guest process runtime runtime guest process runtime host process
Structure of a PVM (2)
loader
load guest code and data
load runtime code
initialization block
allocate memory
establish signal handlers
emulation engine
interpreter and/or translator
code cache manager
manage translated guest code
flush outdated translations
profile database
hold program profile info.
block/edge/invocation profile
OS call emulator
translate OS calls
translate OS responses
exception emulator
handle signals
form precise state
side tables
structures used during emulation
Compatibility
How accurately does the emulation of the guest’s functional behavior compare with its behavior on its native platform - two systems are compatible if, in response to the same sequence of input values, they give the same sequence of output values
Intrinsic compatibility
precise behavior, difficult to achieve
Extrinsic compatibility
accuracy within some well-defined constraints
acceptable for most systems
Extrinsic Compatibility
Compatible for well-defined subset of input sequences - based on VM implementation, architecture/OS specifications, and external guarantees or certificates - some burden on the users to ensure that guarantees are met
e.g., VM may only guaranty accuracy for programs compiled with a particular compiler
e.g., program may be compatible as long as it has limited resource requirements
Verifying Compatibility
Too complex to theoretically prove
except in simple systems
In practice
use informal reasoning
use test suites
Sufficient conditions
decompose compatibility into parts
allows the reasoning process to be simplified
Assume state of guest is 1 to 1 mapped to host
but same “type” of state is not necessary
A Compatibility Framework (2)
Guaranty isomorphic mapping between guest and host states Si SSi' (^) Sj'Guest Host V(Si) (^) V(S j)e (Si ) e'(Si') j
Compatibility Framework (3)
Managing (changes to) program state at two levels
user-managed state
main memory, registers
straightforward mapping between guest and host states
operated on by user-level instructions
OS-managed state
disk contents, I/O state, networks
operated via OS calls, traps, interrupts
operations can affect user-level state as well
Compatibility Framework (5)
Conditions for compatibility
guest state should be equivalent to host state at
control transfer from user instructions to OS
control transfer from OS to user instructions
all user-managed state must be compatible
instruction-level equivalence not required
Trap Compatibility
If source traps, then target traps
If target traps, then source would have trapped
runtime can filter target traps, to remove false ones
Page faults are special case
page fault behavior is non-deterministic w.r.t. user process ... r4 r6 + 1 r1 r2 + r r1 r4 + r r6 r1 * r … trap?Removedead assignment ... R4 R6 + 1 R1 R4 + R R6 R1 * R … Source (^) Target
Memory State Compatibility
Memory state compatibility is maintained if, at the time of a trap or interrupt, the contents of memory are exactly the same in the translated target program as in the original source program. ... R7 R6 << 8 A: mem (R6) R B: mem (R7) R ... ... R7 R6 << 8 B: mem (R7) R A: mem (R6) R ... Protection fault Source (^) Target
Memory Ordering Compatibility
Maintain equivalent consistency model
Important for multiprocessors A = Flag = 0; Process P A = 1; Flag = 1; Process P while (Flag == 0); .... = A;
Constructing a Process VM
Mapping of user-managed state
held in registers
held in memory
Perform emulation (operations to transform state)
memory architecture emulation
instruction emulation
exception emulation
OS emulation
State Mapping
Map user-managed register & memory state - guest data and code map into host’s address space - host address space includes runtime data and code - guest state does not have to be maintained in the same type of resource
Register mapping
straight-forward
depends on number of guest and host registers Guest CodeGuest DataVM Data VM Code Guest Registers Host RegistersHost ABI Address Space Host Register Space