Download 165.92 Kb.
A SIC based Virtual Machine
Anoop U.Thomas, Hari Sankar S, V. Hariharan and Santhosh N.Raju
Computer Science and Engineering,
College of Engineering,
India – 695004
Table Of Contents
With the advent of faster processors and larger memory sizes for cheaper prices even at the reach of an average home user, the concept of virtualization has taken a new turn.
Virtualization is the process by which multiple computers are emulated within a single computer. This includes full scale emulation of a computer including the processor, memory, storage and the various peripherals that are present in an actual computer. Such emulation gives the user the ability to run multiple operating systems simultaneously in real time.
With virtualization one can add / remove hardware, run multiple operating systems like windows and linux side by side etc on the individual virtual machines without the need of switching off or restarting the actual computer hence reducing maintenance cost, development cost, hardware cost etc.
A Virtual Machine consists of the Virtual Machine Monitor and the Virtual Machine itself. The Virtual Machine Manages the guest Operating System and the Virtual Machine Monitor manages the Virtual Machines.
In our project we wish to model a Virtual Machine based on a Simplified Instructional Computer (SIC). The Machine will emulate all the hardware of a SIC and will be able to run any program that is written for the SIC. As for the Virtual Machine Monitor we currently intend to use the host operating system.
We wish to extend this idea to a SIC/XE machine architecture if possible so that it can run a minimal Operating System. We also intend to use this machine as a VM modeling tool for the development of actual existing machines.
Operating System: Linux / Windows
Programming Language: C
Tools Required: gcc, make, gdb, grep etc...
Editors: emacs, vi
II. An Introduction to Emulation, Simulation and Virtualization
A software emulator allows computer programs to run on a platform (computer architecture and/or operating system) other than the one for which they were originally written. Unlike a simulation, which only attempts to reproduce a program's behavior, emulation generally attempts to model to various degrees the state of the device being emulated.
A hardware emulator is a hardware that can run programs for the original hardware without any modification or hardware that has exactly the same function as the original hardware. Example: Printer Emulator (inside the ROM of the printer), FPGA based emulator.
A popular use of emulators is to mimic the experience of running arcade games or console games on Linux, Mac OS X, and Microsoft Windows. Emulating these on modern desktop computers is usually less cumbersome than relying on the original machines. However, software licensing issues may require emulator authors to write original software that duplicates the functionality of the original computer's bootstrap ROM and BIOS, often through high-level emulation.
b. Virtual Machines and Virtualization
The term virtual machine is now also used to refer to the environment created by an emulator, where software is used to emulate an operating system for the end user. This is done to allow applications written for one OS to be executed on a machine which runs a different OS; or to 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.
Virtualization is the process by which one is able to run multiple operating systems on a single machine. This is similar to multitasking except that one does the multitasking with the operating systems. That is different Operating Systems on the same system at the same time. With Virtualization one can multitask between operating systems with ease.
In a theoretical sense, the Church-Turing thesis [TOC, Hopcroft & Ullmann] implies that any operating environment can be emulated within any other. In practice, it can be quite difficult, particularly when the exact behavior of the system to be emulated is not documented and has to be deduced through reverse engineering. It also says nothing about timing constraints; if the emulator does not perform as quickly as the original hardware, the emulated software may run much more slowly than it would have on the original hardware.
This can be done using three major ways:
In order to achieve Virtualization we need to have two things.
Virtual Machine (VM): Is the heart and soul of Virtualization. It emulates the required necessary machine features so that we can have a virtual computer within a computer. The virtual machine emulates everything that a normal computer would do. This is the part that hosts the guest operating systems on the target machine.
Virtual Machine Monitor (VMM): This is the more complicated part of the Virtualization process. Current generation VMs are supported by the host computer’s Operating System and these operating systems act as the VMM. The VMM’s main job is to realize the requests generated by each of the VM and process them accordingly so that one VM does not interfere with another. In near future we can see VMMs that are exclusive to handle VM at hardware level. Such a VMM will be nothing more than a highly specialized operating system that exclusively supports running of VM and manages them.
Technologies like Intel Vanderpool Technology and AMD Pacifia Technology aim at bringing virtualization to hardware level and hence avoid hassles of current generation of Software Virtualization Solutions provided by companies like VMware.
Advantages of Virtualization
Issues Facing Virtualization
Simulation is an attempt to imitate functions of a device. Rather than imitating the real hardware it just simulates the functions of the device. In computer programming, a simulator is often used to execute a program that has to run on some inconvenient type of computer.
For example, a program imitating the Pacman arcade hardware and running real Pacman ROM on it is an emulator. A Pacman game written for your computer but using graphics similar to the real arcade is a simulator.
One of the main differences between a VM and a Simulator is that a VM emulates a given computer system with a specific hardware such that it is like running that very computer but in a simulator we only get a sense of the hardware and actual computer system is not emulated. E.g.: An 8085 based Virtual Machine will have a BIOS, Bootloader, an OS Loader etc which in turn can emulate a full computer with 8085 processor, along with various attached peripherals like HDD, FDD etc with individual emulation for each. But in case of a 8085 Simulator one just has a 8085 based system being simulated on a GUI but does not have advanced features like memory management, peripheral handling etc
III. A Background on SIC
SIC stands for Simplified Instructional Computer (SIC) that is used to present fundamental software concepts. The Machine is a theoretical Machine described in the book “System Software” by “Leland L.Beck”. Many advanced details of machines are omitted in order to explain the working of various features of a machine in simpler detail.
One of the major advantages of such an approach is that it is easy to explain the details of system level softwares like Assemblers, Loaders, Linkers etc based on a simplified Architecture. And the idea can be extended to any other actual existing machine by extending the features of the SIC machine. There by adding or removing the features from the SIC assembler we can get the required target machine assembler.
Why choose SIC to make a VM?
This is one major question that arises when we consider this project. One of the things we found during the preliminary analysis of the project was that we couldn’t find a proper simplified basis for representing a VM for development purposes. The open source counterparts where a bit too complex and not well documented eg: bochs, Xen etc.
Another problem that we faced was during the course of our course history. We had to study about SIC and develop programs like assemblers, loaders etc but had no place to test or execute the programs developed. Most of the time the ordeal ended with obtaining an object code or showing the possible memory locations where the object programs where loaded.
Hence we decided to develop a SIC based Virtual Machine so that we can achieve the above two goals. As a part of this achieving this goal we wish to submit this project to College of Engineering, Trivandrum. So that students in the following semester will have a better chance of seeing their code work and improve the features of the SIC we implement.
IV. THE SIC Machine Specifications
V. The Structure of SICvm
Typically, an emulator is divided into modules that correspond roughly to the emulated computer's subsystems. Most often, an emulator will be composed of the following modules:
Almost all of the Machine Instruction etc are implemented in the file “sic.c”
a. The CPU
Each Register in SIC is emulated by declaring it as a Variable.
//Registers in SIC
int A; //Accumulator
int X; //Index Register
int L; //Linkage Register
int PC; //Program Counter
int SW; //Status Word
Fetch and Store
The CPU accomplishes the basic fetch and store routine through two C functions called fetch() and store() respectively. The working of the two will be explained in detail in the memory subsystem.
The Basic CPU functioning is implemented using the following algorithms
The Fetch Cycle
All instruction execution starts off with a fetch. Fetches are of 3 different types and is dependent upon from where the fetch is called. After fetching the opcode, it’s type is identified and then an operand fetch is performed. After which it is executed.