Emulation

From TracingWiki

Jump to: navigation, search

In a virtual, emulated, environment, total control over the emulated system is possible. Every emulated instruction execution or memory access is visible and can be instrumented. For example, the boot-up code for new microprocessors is often run on a gate level simulation of the new processor.

This flexibility, however, comes at a price in performance. A program may run 10 or 100 times slower on an emulated system. If the simulation is cycle accurate, i.e. the emulated elapsed time is measured accurately, it is possible to measure precisely the performance of the emulated system even if it runs much slower than real time. This is often used to measure the processor pipeline or the cache memory performance. The slower that real-time execution speed is problematic either if the resulting elapsed time is too large, or if the system interacts with other real-time systems. For instance, analyzing the performance of a server answering numerous Web requests, and interacting with a high performance disk subsystem and database servers, would not be easily possible under emulation.

There have been more recently emulators with much better performance. They analyze code sequences before they are executed and replace them with equivalent binary instructions for the system running the emulation. The code sequences are kept in a cache are are reused when encountered subsequently. This technique has been used to emulate different architectures (e.g. ARM on I386), or to emulate a complete processor (with its privileged mode) from within a single process (thus providing one or more virtual systems within a physical system). Qemu is a prime example of a system which does both, while VMWare is a popular commercial package for virtualization on the i386. Another emulation system, Valgrind, is used primarily for instrumenting programs and helping in validation (initialized memory accesses, proper use of malloc and free) and performance analysis (cache and heap profiler).

Personal tools