A virtual machine, also called a hypervisor, allows us to run one Operating System within another operating system. It achieves this by creating a virtual environment that imitates the desired operating system while laying over the base operating system. There are a number of free virtual machine applications available for download. These programs can be installed and used just like any other program on a computer. All computer programs work, more or less, the same way; virtual machines are no exception to this. Thus, an understanding of computer programs will pave way towards a far better understanding of how virtual machines work.
“A virtual machine or VM abstracts hardware of a single computer into several different execution environment”
At the most rudimentary level of computing, the programs work on two modes:
- Kernel mode
The computer codes, in kernel mode, have unrestricted access to the underlying computer’s hardware like ram, storage, CPU, etc. Because the codes in kernel mode have unbiased access to computer resources, only the most trusted programs (like operating system) are granted access to run on kernel mode.
- User mode
The executing codes, in user mode, have no direct access to the computer’s resources. The switch to a kernel mode- from user mode- occurs when an application request an operating system to allocate a hardware resource to it.
How programs implement with the system
A kernel is responsible for interacting with the hardware. Any process that is run in the system evokes a kernel program, which in turn converses with the hardware and delivers output. These outputs appear as inputs to user mode codes. This cycle of feeding output obtained from kernel code as input to user code continues until a desired result is obtained.
How virtual machines implement with the system
A virtual machine application works like any other computer application. A virtual machine implementation runs the kernel code and interacts with computer resources. There can be multiple virtual machine environment on a single system. However, running a number of VM environments in a machine can slow down the process as more resources are being used at one time. All the VM environments request access to the resources through VM implementation.
A VM creates an illusion as if each separate execution environment were running its own private resource. It achieves this by allocating portions of resources to each environment. The resource being used by one of the environment never coincides with that of another environment. Thus, though the underlying hardware is same for all the VMs, the same resource is never shared by any other virtual machine.
A virtual machine application, like any other application, has two components:
- Virtual machine software- that runs in the kernel mode and gets to allocate, use, and interact with the hardware; and does bifurcation of the resources for the use of Virtual machines in the system.
- The Virtual Machine itself, that operates on user mode.
A VM creates its own virtual user mode and a virtual kernel mode– both of which run on physical user mode. For each of the VMs there are two underlying operations (kernel operations and user operation), even though there is no resource to interact directly.
Benefits of a virtual machine
Multiple OS can run on the same computer. This allows users to run old programs that have been discontinued, or are somewhat unstable with the recent OS updates, without the need to stick to the outdated OSs just to run a program.
It eliminates the need for having a number of machines with different platforms. Instead, we can have one machine with sound processing capabilities, and run it on diverse platforms through virtual environment. With a number of so-cheap-as-if-free VM hosting services, it becomes an economically viable way of having numerous platforms without buying separate machine for each platform.
Protection of resources- Each VM has its own resource to use. Allocating specific resources makes sure that any over-the-top usage of CPU by any of the VMs does not affect the efficiency of other VMs. The same technique is nowadays implemented in Windows VPS hosting, primarily because it helps create a sanctuary of resources.
Developers and network administrators have to intensely test the compatibility of their applications on varied platforms. A virtual machine allows them to perform trial runs of applications, on a single computer, before they can be rolled out for public use.
Limitations
Virtual machines operate slower than the real machines, because it indirectly accesses the hardware. The performance of the system drastically reduces with the addition of fresh VM to the system. Also, VMs don’t work as efficiently as the real machines.
The resources allocated to a virtual machine might not be sufficient enough to carry the operations swiftly. The real machine may not be able to run even the base OS well.
The virtual machines inherit the weaknesses of the host machine; a host machine infected with virus is likely to infect the VMs run on it.
The virtual machines, though sound like a unique concept, work in a similar way as most other applications. The use of VM is more popular among developers. VMs very well molded themselves to adapt with the advancement in computer technology. Owing to the benefits that they provide, the use of VM is almost inevitable, especially for developers.