Sunteți pe pagina 1din 41

Concept of Virtual Machine

Introduction
Virtual Machines are a concept that is used to solve problems in the computing world. E.g. Hardware sharing among many programs, Portable software among OS, etc. Virtual machine appearance of a machine that is not actually there.

Concept of Machine
Machine

INPUT

OUTPUT

Instructions

All kinds of machine are designed to carry out certain set of instructions.

Instructions of Machines
Different machine needs different set of instruction.
Instruction for X machine

X machine

Instruction for Y machine

Y machine

Virtual Machine
Virtual Machine of Y machine

Instruction for X machine

X machine

Maps

Instruction for Y machine

Advantages of VM
This can allow applications written for one OS to be executed on a machine which runs a different OS, or provide execution "sandboxes" which provide a greater level of isolation between processes than is achieved when running multiple processes on the same instance of an OS. One use is to provide multiple users the illusion of having an entire computer, one that is their "private" machine, isolated from other users, all on a single physical machine. Another advantage is that booting and restarting a virtual machine can be much faster than with a physical machine, since it may be possible to skip tasks such as hardware initialization.

Software virtualization can be done in four major ways:


Emulation, full system simulation, or "full virtualization with dynamic recompilation" the virtual machine simulates the complete hardware, allowing an unmodified OS for a completely different CPU to be run. Paravirtualization the virtual machine does not simulate hardware but instead offers a special API that requires OS modifications. The most profound example of this is XenSource's XenEnterprise (www.xensource.com) Native virtualization and "full virtualization" the virtual machine only partially simulates enough hardware to allow an unmodified OS to be run in isolation, but the guest OS must be designed for the same type of CPU. The term native virtualization is also sometimes used to designate that hardware assistance through Virtualization Technology is used.

4 Virtual Machine Models


IBM Model Java Model OSI Model Unix Model

IBM Virtual Machine Model


Virtual machine is an exact copy of a real machine with reduced memory. A large and powerful mainframe computer is split up or partitioned into many virtual machines with less resources available than the original mainframe computer. Instructions enjoy one-to-one mapping. It provides a way to share large systems with multiple users in a secure and stable way.

Java Virtual Machine Model


An example of simulated machine. A new VM is placed on the current system, lending its distinct functionality to the user without altering the system. Maps every instruction of a machine with a virtual instruction. Allow programs portability if same JVM is installed on two completely different machines.

Application virtual machine


Another meaning of virtual machine is a piece of computer software that isolates the application being used by the user from the computer. Because versions of the virtual machine are written for various computer platforms, any application written for the virtual machine can be operated on any of the platforms, instead of having to produce separate versions of the application for each computer and operating system. The application is run on the computer using an interpreter or Just In Time compilation. One of the best known examples of an application virtual machine is Sun Microsystem's Java Virtual Machine.

JVM
Java Source Code
Compile

Java Byte Code

Run

With JRE

JVM

Actual Computer

OSI Virtual Machine Model


The underlying sub sets of instructions are hidden from the observer. i.e. each successive layer of instructions, machine circuitry, machine code, operating system instructions, and application program code, hides the underlying levels of instructions from the next user. It is to build capabilities and simulated devices that do not actually exist physically in the computer.

OSI Virtual Machine Example


Combined Instructions
Hard disk

Hard disk

Users view showing a single unified hard disk.

Hard disk

Unix Virtual Machine Model


Unix uses a series of independent processes to accomplish user commands. Each Unix process can be viewed conceptually as a virtual machine. The Unix operating system is constructed to provide a uniform set of distinct library services to user processes in execution. Therefore the shell program is portable.

Virtual Machines
A virtual machine takes the layered approach to its logical conclusion. It treats hardware and the operating system kernel as though they were all hardware A virtual machine provides an interface identical to the underlying bare hardware The operating system creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory

Virtual Machines (Cont.)


The resources of the physical computer are shared to create the virtual machines
CPU scheduling can create the appearance that users have their own processor Spooling and a file system can provide virtual card readers and virtual line printers A normal user time-sharing terminal serves as the virtual machine operators console

Virtual Machines (Cont.)

Non-virtual Machine

Virtual Machine

Virtual Machines (Cont.)


The virtual-machine concept provides complete protection of system resources since each virtual machine is isolated from all other virtual machines. This isolation, however, permits no direct sharing of resources. A virtual-machine system is a perfect vehicle for operating-systems research and development. System development is done on the virtual machine, instead of on a physical machine and so does not disrupt normal system operation. The virtual machine concept is difficult to implement due to the effort required to provide an exact duplicate to the underlying machine

VMware Architecture

The Java Virtual Machine

Javabyte Code:

JAVABYTE code generators

* Jikes, compiles from the Java programming language to Java bytecode

* JGNAT and AppletMagic, compile from the Ada programming language to


Java bytecode * Espresso, compiles from the Java programming language to Java bytecode, only Java 1.0 * Gnu Compiler for Java, GCJ, compiles from the Java programming language to Java bytecode, is also able to compile to native machine code. * Groovy programming language, A scripting language based on java If executing Java bytecode in a Java virtual machine is not desirable, a developer can also compile Java source code or Java bytecode directly to native machine code with tools such as the GNU Compiler for Java.

Common Intermediate Language


Formerly called Microsoft Intermediate Language or MSIL Is the lowest-level human-readable programming language in the Common Language Infrastructure and in the .NET Framework. Languages which target the .NET Framework compile to CIL, which is assembled into bytecode. CIL resembles an object-oriented assembly language, and is entirely stack-based. It is executed by a virtual machine. The primary .NET languages are C#, Visual Basic .NET, C++/CLI, and J#. CIL was originally known as Microsoft Intermediate Language (MSIL) during the beta releases of the .NET languages. Due to standardization of C# and the Common Language Infrastructure, the bytecode is now officially known as CIL. Because of this legacy, CIL is still frequently referred to as MSIL, especially by long-standing users of the .NET languages

Just-In-Time (JIT) Compilation


Just-in-time compilation involves the byte-code being turned into code immediately executable by the CPU. The conversion is performed gradually during the program's execution. JIT compilation provides environment-specific optimization, runtime type safety, and assembly verification. To accomplish this, the JIT compiler examines the assembly metadata for any illegal accesses and handles violations appropriately.

NGEN (Native Image Generator) Compilation


NGEN produces a native binary image for the current environment. The byte-code is either skipped entirely or converted into native CPU instructions completely before runtime. This eliminates the JIT overhead at the expense of portability; whenever an NGEN-generated image is run in an incompatible environment, .NET framework automatically reverts to using JIT.

S-ar putea să vă placă și