Current mainstream virtual machines
At present, the popular virtual machine softwares are VMware ACE and Virtual PC, both of which can virtualize multiple computers on Windows system for installing other operating systems such as Linux, OS/2 and FreeBSD. After Microsoft acquired Connectix in February 2003, Microsoft Virtual PC 2004 was released soon. However, due to various considerations, the newly released Virtual PC 2004 no longer explicitly supports Linux, FreeBSD, NetWare, Solaris and other operating systems, and only keeps OS/2. If you want to virtualize a Linux computer, you can only set it manually. Comparatively speaking, VMware is obviously superior to Virtual PC 2004 in multi-operating system support and execution efficiency. One computer becomes two, and learning to use Linux is no longer a worry.
Virtualization classification
Virtualization wave
Microsoft virtualization
IBM virtualization
HP Virtualization
Software virtualization
SUN virtualization
Intel Virtualization
AMD virtualization
java virtual machine
There are many versions of VMware 4.5, such as workstations and GSX servers, among which the Windows version of workstations is the most widely used. On this basis, this paper carries out various practical exercises.
The concept of virtual machine is relatively broad. Usually people are exposed to the concept of virtual machine, including hardware simulation software like VMware and software between hardware and compiler like JVM. This refers to the latter.
A virtual machine is an abstract computer, which, like a real computer, has an instruction set and uses different storage areas. It is responsible for executing instructions and managing data, memory and registers. This virtual machine provides a unique interface for compilers on any platform. The compiler only needs to face the virtual machine, generate the code that the virtual machine can understand, and then the interpreter converts the virtual machine code into the machine code of a specific system for execution.
Sun xVM VirtualBox has released a new version: 2. 1.0.
2. 1.0 doesn't mainly fix bugs and improve the original functions like the previous 2.0.X This version adds many new functions. It is strongly recommended that users of VBox update!
On ChangeLog in official website, we can see the main update information of this version:
* Hardware virtualization technologies (VT-x and AMD-V) supporting Max OS X clients;
* Support to simulate a 64-bit client on a 32-bit operating system! (For experimental nature, please refer to the user manual for details);
* Support Intel Nehalem virtualization enhancement technology (EPT and VPID, see user manual for details);
* Support 3D acceleration through OpenGL! (See Chapter 4.8 of the User Manual);
There are many updates, but the above four items alone have enough reasons for users to upgrade!
VirtualBox finally supported 3D acceleration through OpenGL experiments, and took the lead in supporting the simulation of 64-bit clients on 32-bit operating systems (64-bit CPU support is required). This means fewer restrictions on the virtual machine platform. You can simulate AMD64 on your x86 platform!
As for "OpenGL 3D acceleration", I understand that this function is only available in Windows system at present, and only OpenGL acceleration can be realized, but there is no Direct3D acceleration. This means that you can already run some OpenGL 3D applications in the Windows virtual machine, but Direct3D will have to wait for a while.
What are you waiting for? This is a greatly improved version. Download and try it quickly:
Why do individuals use virtual machines?
1. demo environment, which can easily install various examples;
2. Ensure the fast operation of the host, and reduce unnecessary junk installation programs, occasionally used programs or test programs running on the virtual machine;
3. Avoid reloading common tools such as banks every time, which are not commonly used and require good confidentiality, and run in one environment alone;
4. I want to test the unfamiliar application and install it in the virtual machine to delete it completely;
5. Experience different versions of operating systems, such as Linux and Mac.
Some instances that use virtual machines
Example 1: Due to the increasing influence of computer network in our daily life, many schools list network-related courses as compulsory or elective courses. Network course is a course that pays equal attention to theory and practice. If we simply teach network-related knowledge and do not provide students with an experimental environment, it will be difficult to arouse students' interest in the network, lead to learning difficulties, and even make students resist online courses. Therefore, while paying attention to theoretical teaching, many schools also actively carry out related network experiment courses.
In order to solve these problems, one of the simplest solutions is to use virtual machine software to build a small network environment, so that students can learn the communication principles of the network in this simulated network environment and then have the ability to develop network applications.
Terminal virtualization is sought after because of its greatly reduced maintenance cost, such as reducing occupied space, reducing the cost of purchasing software and hardware equipment, saving energy and reducing maintenance costs. Compared with the actual terminal equipment, it has more cost-effective advantages. But these are not the only reasons why the education industry and manufacturers have a soft spot for virtualization technology. On the other hand, we seldom mention that virtualization technology can greatly improve the security of the system.
[Edit this paragraph ]VMware virtual machine installation process
VMware Workstation virtual machine is an application running on Windows or Linux computer, which can simulate the standard PC environment based on x86. This environment, like a real computer, has chipset, CPU, memory, graphics card, sound card, network card, floppy drive, hard disk, CD-ROM drive, serial port, parallel port, USB controller, SCSI controller and other devices. The window that provides the application program is the display of the virtual machine.
In use, this virtual machine is not much different from the real physical host. It needs to partition, format, install operating system, install applications and software. In short, everything is just like a real computer.
The following is an example to introduce the method and steps of creating a virtual machine using VMware Workstation.
1. Run VMware Workstation 6, and click File → New → Virtual Machine to enter the virtual machine creation wizard, or press Crtl+N directly to enter the virtual machine creation wizard.
2. Click the "Next" button in the welcome page that pops up.
3. Select the Custom radio button in the Virtual Machine Configuration option area.
4. On the Select Virtual Machine Hardware Compatibility page, select the hardware format of the virtual machine. You can select VMware Workstation 6, VMware Workstation 5 or VMware Workstation 4 in the hardware compatibility drop-down list box. Workstation 6 format is usually chosen because the new virtual machine hardware format supports more functions. Click "Next" button after selection.
5. In the Select Guest Operating System dialog box, select the type of virtual machine to create and the operating system to run. Here, select the Windows 2000 Professional operating system, and then click Next.
6. In the Name Virtual Machine dialog box, name the newly created virtual machine and select its saving path.
7. Select the number of CPUs in the virtual machine in the processor options area. If you choose two, the host needs two CPUs or hyper-threading CPUs.
8. In the memory page of the virtual machine, set the memory used by the virtual machine. Generally, for systems below Windows 98, 64MB can be set; For Windows 2000/XP, at least 96MB can be set; For Windows 2003, the minimum is128 MB; ; For Windows Vista virtual machines, the minimum value is 5 12MB.
9. Select the network type of the virtual machine network card in the Network Type page.
Select the first option, and use the bridge network card (VMnet0 virtual network card), which means that the current virtual machine is in the same network as the host (the computer running VMware Workstation software).
Choose the second option, and use NAT network card (VMnet8 virtual network card), which means that the virtual machine accesses the host and the network outside the host in one direction through the host, and computers in the network outside the host cannot access the virtual machine.
Select the third option and only use the local network (VMnet 1 virtual network card), which means that the virtual machine can only access the host and all virtual machines using VMnet 1 virtual network card. Computers in the network other than the host cannot access the virtual machine, nor can they be accessed by the virtual machine.
Select the fourth item, No network connection, which means that there is no network connection between the virtual machine and the host.
10. On the Select I/O Adapter Type page, select the SCSI card model of the virtual machine, which is usually the default value.
1 1. On the Select Disk page, select Create New Virtual Disk.
12. On the Select Disk Type page, select the interface method of the created virtual hard disk, which is usually the default value.
13. Set the virtual disk size in the Specify Disk Capacity page. In general, you can choose the default value.
14. Set the name of the virtual disk file in the disk file options area of the specified disk file page, usually select the default value, and then click Finish.
Install the operating system
There is no difference between installing an operating system in a virtual machine and installing it in a real computer, but when installing an operating system in a virtual machine, you can directly use the installation CD image (or floppy disk image) saved on the host as the optical drive (or floppy disk drive) of the virtual machine.
You can open the Windows 2000 virtual machine configuration file created above, select the CD-ROM project in the hardware tab of the virtual machine settings page, select the use ISO image radio button in the connection options area, and then browse and select the Windows 2000 installation CD image file (ISO format). If you use an installation CD, select Use a physical drive and select the optical drive where the installation CD is located.
After selecting the optical drive, click the play button on the toolbar to turn on the power of the virtual machine, and click with the mouse in the virtual machine work window to enter the virtual machine.
Explain that if you want to switch back to the host from the virtual machine window, you need to press Ctrl+Alt hotkey.
Install VMware tools
After installing the operating system in the virtual machine, you need to install VMware Tools. VMware Tools is equivalent to motherboard chipset driver, graphics card driver and mouse driver of VMware virtual machine. After installing VMware Tools, the performance of the virtual machine can be greatly improved, and the resolution of the virtual machine can be set to any size. You can also use the mouse to switch directly from the virtual machine window to the host.
1. Select Install VMware Tools from the virtual machine menu.
2. Follow the prompts to install, and finally restart the virtual machine.
[Edit this paragraph ]Java virtual machine
First, what is a Java virtual machine?
Java Virtual Machine (JVM) is short for Java Virtual Machine. It is a fictional computer, which is realized by simulating various computer functions on the actual computer. Java virtual machine has its own perfect hardware architecture, such as processor, stack, register and so on. , and there is also a corresponding instruction system.
1. Why use a Java virtual machine?
A very important feature of Java language is that it has nothing to do with the platform. Using Java virtual machine is the key to realize this function. If a common high-level language is to run on different platforms, it needs to be compiled into different object codes at least. After the introduction of Java virtual machine, Java language does not need to be recompiled when running on different platforms. Java language usage mode Java virtual machine shields the information related to a specific platform, so that the Java language compiler can run on various platforms only by generating the object code (bytecode) running on the Java virtual machine without modification. When Java virtual machine executes bytecode, it interprets bytecode as the execution of machine instructions on a specific platform.
2. Who needs to know about Java virtual machines?
Java virtual machine is the foundation of the underlying implementation of Java language, and anyone interested in Java language should have a general understanding of Java virtual machine. This helps to understand some properties of the Java language and use it. For the software personnel who want to realize the Java virtual machine on a specific platform, the compiler author of Java language, and those who want to realize the Java virtual machine with hardware chips, they must have a deep understanding of the specifications of the Java virtual machine. In addition, if you want to extend the Java language or compile other languages into bytecode of the Java language, you also need to have a deep understanding of the Java virtual machine.
Data types supported by 3.Java virtual machines.
The basic data types of Java language supported by Java virtual machine are as follows:
Byte:/1byte's complement of signed integer.
Short://2/ Two-byte signed integer's complement
Int://4/4 Byte's Complement of Signed Integer
Long://8/8 byte's complement of signed integer.
Float://4-byte IEEE754 single-precision floating-point number
Double://8-byte IEEE754 double-precision floating point number
Char://2 bytes unsigned Unicode character
Almost all Java type checking is done at compile time. The data of the original data types listed above do not need to be marked with hardware when Java executes. Byte codes (instructions) that manipulate these primitive data types have indicated the data types of operands. For example, iadd, ladd, fadd and dadd instructions are all the addition of two numbers, and the operand types are int, long, float and double. The virtual machine does not set a separate instruction for Boolean types. Boolean data is processed by integer instructions, including integer return. Boolean arrays are processed with byte arrays. Virtual machines use floating-point numbers in IEEE754 format. Old computers that do not support IEEE format may be very slow when running Java numerical calculation programs.
Other data types supported by virtual machines include:
Object// 4-byte reference to Javaobject (object)
ReturnAddress//4 bytes, used for jsr/ret/jsr-w/ret-w instruction.
Note: Java arrays are treated as objects.
The specification of the virtual machine has no special requirements for the internal structure of the object. In Sun's implementation, the reference to an object is a handle, which contains a pair of pointers: one pointer points to the method table of the object, and the other points to the data of the object. The program represented by bytecode of Java virtual machine should conform to the type rules. The implementation of Java virtual machine should refuse to execute bytecode programs that violate the type regulations. Due to the limitation of bytecode definition, it seems that Java virtual machine can only run on machines with 32-bit address space. But you can create a Java virtual machine and automatically convert bytecode into 64-bit format. From the data types supported by Java virtual machines, we can see that Java strictly stipulates the internal format of data types, which makes the interpretation of data consistent in the implementation of various Java virtual machines, thus ensuring the platform independence and compatibility of Java.
Portability.
Second, the Java virtual machine architecture
Java virtual machine consists of five parts: a set of instruction sets, a set of registers, a stack, a garbage collection heap and a method area. These five parts are logical components of the Java virtual machine, and do not depend on any implementation technology or organization, but their functions must be realized on the real machine in some way.
1.Java instruction set
The Java virtual machine supports about 248 bytecodes. Each bytecode performs a basic CPU operation, such as adding an integer to a register, subroutine transfer, etc. The Java instruction set is equivalent to the assembly language of Java programs.
Instructions in the Java instruction set contain a single-byte operator to specify the operation to be performed, and zero or more operands to provide parameters or data needed for the operation. Many instructions have no operands and only contain a single-byte operator.
The execution process of virtual machine internal loop is as follows:
Do {
Take an operator byte;
Performing an operation according to the value of the operator;
}while (program not completed)
Because of the simplicity of the instruction system, the execution process of the virtual machine is very simple, which is beneficial to improve the execution efficiency. The number and size of operands in an instruction are determined by operators. If the operand is greater than one byte, its storage order is high byte first. For example, the 16 bit parameter takes up two bytes when stored, and its value is:
The first byte *256+ the second byte bytecode instruction stream is usually byte aligned. The exceptions are the directives tabltch and lookup, where mandatory 4-byte boundary alignment is required.
Step 2 register
The register of Java virtual machine is used to save the running state of the machine, which is similar to some special registers in microprocessor.
Java virtual machines have four kinds of registers:
Pc:Java program counter.
Optop: a pointer to the top of the operand stack.
Frame: a pointer to the execution environment of the current execution method.
Vars: a pointer to the first variable in the local variable area of the currently executing method.
java virtual machine
Java virtual machines are stacked. It does not define or use registers to pass or accept parameters. Its purpose is to ensure the simplicity of instruction set and the efficiency of implementation (especially for processors with fewer registers).
All registers are 32-bit.
Step 3 pile up
The stack of Java virtual machine has three areas: local variable area, running environment area and operand area.
(1) local variable region
Each Java method uses a set of fixed-size local variables. They are addressed according to the word offset of the vars register. Local variables are all 32-bit. Long integers and double-precision floating-point numbers occupy the space of two local variables, but are addressed according to the index of the first local variable. (For example, if a local variable with index n is a double-precision floating-point number, it actually occupies the storage space represented by indexes n and n+ 1. The virtual machine specification does not require that 64-bit values in local variables be 64-bit aligned. The virtual machine provides instructions to load values in local variables into the operand stack, and also provides instructions to write values in the operand stack into local variables.
(2) Operating environment area
The information contained in the runtime environment is used for dynamic linking, normal method return and exception propagation.
Dynamic connection
The runtime environment includes pointers to the interpreter symbol tables of the current class and the current method to support dynamic linking of method codes. The class file code of the method uses symbols when referring to the method to be called and the variable to be accessed. Dynamic linking translates symbolic method calls into actual method calls, loads necessary classes to interpret undefined symbols, and translates variable accesses into offset addresses corresponding to the runtime storage structures of these variables. Dynamically link methods and variables so that changes in other classes used in methods will not affect the code of this program.
Normal method return
If the current method ends normally, the called method will get the return value when the correct type of return instruction is executed. The execution environment is used to restore the caller's register when the caller returns normally, and increase the caller's program counter by an appropriate value to skip the executed method call instruction, and then continue execution in the caller's execution environment.
Exception and error propagation
Exception is called Error or exception in Java and is a subclass of Throwable class. The reasons in the program are: ① dynamic link error, such as not finding the required class file. (2) runtime errors, such as reference to null pointers.
The program uses the throw statement.
When an exception occurs, the Java virtual machine takes the following measures:
Check the catch clause table associated with the current method. Each catch clause contains its valid instruction range, the type of exception that can be handled, and the address of the code block that handles the exception.
The catch clause that matches the exception should meet the following conditions: the instruction that caused the exception is within its instruction range, and the exception type that occurred is a subtype of the exception type that it can handle. If a matching catch clause is found, the system moves to the specified exception handling block for execution; If the exception handling block is not found, the process of finding the matching catch clause is repeated until all nested catch clauses of the current method are checked.
Since the virtual machine continues to execute from the first matching catch clause, the order in the catch clause table is very important. Because Java code is structured, all exception handlers of a method can always be arranged in a table in sequence, and for any possible program counter value, the appropriate exception handling block can be found in linear order to handle the exceptions that occur under the program counter value.
If no matching catch clause is found, the current method will get an "exception not intercepted" result and return it to the caller of the current method as if the exception had just occurred in its caller. If the corresponding exception handling block is still not found in the caller, then this error propagation will continue. If the error propagates to the top level, the system will call the default exception handling block.
(3) The machine instructions in the operand stack area only take operands from the operand stack, perform operations, and return the results to the stack. Stack structure is chosen because it can effectively simulate the behavior of virtual machines on machines with only a few registers or non-general registers (such as Intel486). The operand stack is 32 bits. It is used to pass parameters to methods and receive results from methods, and it is also used to support parameters of operations and save results of operations. For example, the iadd instruction adds two integers. The two integers added should be the two words at the top of the operand stack. These two words were pushed onto the stack by the previous instruction. These two integers will pop off the stack, add up, and push the result back to the operand stack.
Each primitive data type has special instructions to perform necessary operations on them. Each operand needs a storage location in the stack, except for long and double types, which need two locations. Operands can only be operated by operators suitable for their types. For example, it is illegal to press two numbers of type int and treat them as numbers of type long. In Sun's virtual machine implementation, this restriction is enforced by bytecode validator. However, there are some operations (operators dupe and swap) that operate on the runtime data area, regardless of its type.
4. Garbage collection piles
Java's heap is a runtime data area from which instances of classes (objects) allocate space. The Java language has the ability to collect useless units: it does not give programmers the ability to explicitly release objects. Java does not specify a specific garbage collection algorithm, and various algorithms can be used according to the requirements of the system.
5. Method area
Method areas are similar to compiled code in traditional languages or body segments in Unix processes. It saves method code (compiled java code) and symbol table. In the current Java implementation, the method code is not included in the garbage collection heap, but it is planned to be implemented in a future version. Each class file contains compiled code of Java classes or Java interfaces. It can be said that the class file is the execution code file of Java language. In order to ensure the platform independence of class files, the format of class files is also described in detail in the Java virtual machine specification. For details, please refer to Sun's Java virtual machine specification.