Virtualization | Komputasi | Suatu Permulaan

Chapter 8 Review of Basic Principles Now after we know about many specific examples of what operating systems do and how they do it, we can distill some basic principles. policy mechanism separation; example: mechanism for priority scheduling, policy to set priorities; mechanism for paging, policy to choose pages for replacement flexibility in changingoptimizing policy, code reuse of mechanism implementation.

8.1 Virtualization

Virtualization is probably the most important tool in the bag of tricks used for sys- tem design. It means that the objects that the system manipulates and presents to its users are decoupled from the underlying hardware. Examples for this principle abound. • Processes are actually a virtualization of the whole computer: they provide the context in which a program runs, including CPU, memory, and IO options. While this is realized by direct execution on the underlying hardware most of the time, some of the resources are modified. For example, certain priviledged instructions are hidden and cannot be used. • Threads, which provide the locus of computation in a program, may be consid- ered as an abstraction of the CPU only. • Virtual memory is the most explicit form of virtualization: each process is pre- sented with an address space that is mapped to the underlying hardware as needed. • Files can be considered as an idealized and virtual storage device: you can store and access your data randomly, without having to worry about the idiosyncrasies of actual devices. At a lower level, logical volumes are a virtualization of disks that does away with the specific size limitations of the hardware. 167 • Network connections are virtualized just like files, with one important restric- tion: data access is sequential, rather than being random. Virtualization typically involves some mapping from the virtual objects to the physi- cal ones. Thus each level of virtualization is equivalent to a level of indirection. While this has its price in terms of overhead, the benefits of virtualization outweigh the cost by far. hide virtualization mapping using caching Virtualization helps resource management most famous in JVM; origins much older virtual machines in MVS virtual memory Virtualization helps protection virtual machines can’t interfere with each other sandbox for mobile code Virtualization helps application construction another example of operating system idea that is moving to applications virtual tree structure for load balancing - gribble In recent years there is a growing trend of using virtualization. This means that it is possible to create multiple virtual copies of the machine called virtual machines, and run a different operating system on each one. This decouples the issue of creat- ing abstractions within a virtual machine from the provisioning of resources to the different virtual machines. A remarkable example is given by VMware. This is actually a user-level applica- tion, that runs on top of a conventional operating system such as Linux or Windows. It creates a set of virtual machines that mimic the underlying hardware. Each of these virtual machines can boot an independent operating system, and run different applications: base hardware machine operating system VMware virtual machine 1 virtual machine 2 operating system operating system app A app B app C app E app D 168 The idea of virtual machines is not new. It originated with MVS, the operating system for the IBM mainframes. In this system, time slicing and abstractions are completely decoupled. MVS actually only does the time slicing, and creates multiple exact copies of the original physical machine. Then, a single-user operating system called CMS is executed in each virtual machine. CMS provides the abstractions of the user environment, such as a file system. As each virtual machine is an exact copy of the physical machine, it was also pos- sible to run MVS itself on such a virtual machine. This was useful to debug new ver- sions of the operating system on a running system. If the new version is buggy, only its virtual machine will crash, but the parent MVS will not. This practice continues today, and VMware has been used as a platform for allowing students to experiment with operating systems. We will discuss virtual machine support in Section 8.1. To read more: History buffs can read more about MVS in the book by Johnson [1]. The operating system is ill-defined As demonstrated by VMware, the issue of what exactly constitutes the operating sys- tem can be murky. In principle, the operating system is the entity that uses the un- derlying hardware to provide the operating environment needed by the application. But what is this for, say, application D? Its environment is created by three distinct layers of software: the host operating system, the VMware system, and the operating system running on virtual machine 1. Alternatively, the virtual machine can be provided by a language runtime environ- ment. The most famous example is JVM, the Java virtual machine. This was defined specifically to divorce Java applications from any dependency on the underlying op- erating system, thus making them completely portable to any system that supports a JVM. Thus this should surely not be considered part of the operating system. A further complication results from the structuring of the operating system. The core of the operating system is called the kernel, and runs in a special protected mode as described below. But it is also possible to use special applications, that are serviced like user applications, but actually perform operating system functions. The benefits of using such a structure are discussed at length in Chapter 11. For now, suffice it to say that it raises the question of whether these applications are part of the operating system or external to it. In this book we’ll ignore such complexities, at least initially. We’ll take the some- what outdated view that all the operating system is a monolithic piece of code — it is all the kernel. But in later chapters we’ll consider some deviations from this viewpoint. 169

8.2 Resource Management