Previous | Next

Virtual Machine Manager

The Virtual Machine Manager manages resources needed for each application and system process running on the computer. Virtual Machine Manager creates and maintains the virtual machine environments in which applications and system processes run.

A virtual machine (VM) is an environment in memory that, from the application’s perspective, looks as if it is a separate computer, complete with all the resources available on the physical computer that an application needs to run. The Virtual Machine Manager, shown in Figure 28.6, provides each application with the system resources it needs.

Figure 28.6 Virtual Machine Manager

Windows 98 has a single VM called the System VM, in which all system processes run. In addition, each Win32-based application runs in its own VM, whereas Win16-based applications share a single Win16 VM. Each MS-DOS- based application runs in its own VM.

Note

Windows NT has the ability to run each Win16-based application in its own VM.

The Virtual Machine Manager is responsible for three key areas of services:

The following sections describe these three areas of service.

Process Scheduling and Multitasking

The Process Scheduler is the component responsible for providing system resources to the applications and other processes you run, and for scheduling processes to allow multiple applications to run concurrently.

The Process Scheduler also schedules processes in a way that allows multiple applications and other processes to run concurrently. Windows 98 uses two methods for concurrent process scheduling — cooperative multitasking and preemptive multitasking.

With Windows 3.1, applications ran concurrently through a method known as cooperative multitasking. Using this method, the operating system required an application to check the message queue periodically and to relinquish control of the system to other running applications. Applications that did not check the message queue would effectively "hog" CPU time and prevent the user from switching to another application. For compatibility reasons, Windows 98 cooperatively multitasks Win16-based applications.

Windows 98 uses preemptive multitasking for Win32-based applications. This means that the operating system takes control away from or gives control to another running task, depending on the needs of the system.

Unlike Win16-based applications, Win32-based applications do not need to yield to other running tasks to multitask properly. Win32-based applications can take advantage of multithreading, a mechanism that Windows 98 provides to facilitate the ability to run applications concurrently. A Win32-based application running in the system is called a process in terms of the operating system. Each process consists of at least a single thread of execution that identifies the code path flow as it is run by the operating system. A thread is a unit of code that can get a time slice from the operating system to run concurrently with other units of code, and must be associated with a process. However, a Win32-based application can initiate multiple threads for a given process to enhance the application for the user by improving throughput, enhancing responsiveness, and aiding background processing. Because of the preemptive multitasking nature of Windows 98, threads of execution allow code to be smoothly processed in the background.

A good illustration of this is the Windows 98 shell itself. Although the shell is a Win32-based process, each folder window that opens is a separate thread of execution. As a result, when you initiate a copy operation between two, shell folder windows, the operation is performed on the thread of the target window. You can still use the other windows in the shell without interruption, or you can start a different copy in another window.

In another example, a word processing application (a process) can implement multiple threads to enhance operation and simplify interaction with the user. The application can have a separate thread that responds to keys typed on the keyboard by the user to place characters in a document, while another thread performs background operations, such as spelling checking or paginating, and a third thread spools a document to the printer in the background.

Note

Some Win16-based applications may have provided similar functionality; however, because Windows 3.1 did not provide a mechanism for supporting multithreaded applications, it was up to application vendors to implement their own threading schemes. The use of threads in Windows 98 makes it easy for application vendors to add asynchronous processing of information to their applications.

Memory Paging

Windows 98, like Windows NT, uses a demand-paged virtual memory system. This system is based on a flat, linear address space, accessed using 32-bit addresses.

Each process is allocated a unique virtual address space of 2 gigabytes (GB). The upper 2 GB is shared, while the lower 2 GB is private to the application. This virtual address space is divided into equal blocks, or pages.

Demand paging is a method by which code and data are moved in pages from physical memory to a temporary paging file on disk. As the information is needed by a process, it is paged back into physical memory on demand.

The Memory Pager maps virtual addresses from the process address space to physical pages in computer memory. In doing so, the Memory Pager hides the physical organization of memory from the process threads. This ensures that the thread can access the memory of its process as needed, but not the memory of other processes. Therefore, as shown in Figure 28.7, the virtual memory of a thread process is much simpler than the real arrangement of pages in physical memory.

Figure 28.7 Memory mapping with Memory Pager

To support a 16-bit operating environment including Windows 3.1 and MS-DOS, the Intel processor architecture uses a mechanism called a segment. Segments reference memory by using a 16-bit segment address, and a 16-bit offset address within the segment. A segment is 64 KB in size, and performance of both applications and the operating system suffer for accessing information across segment boundaries. Windows 98 supports this memory model for backward compatibility to Win16-based applications that were written for it by providing emulation by the Win16 subsystem.

For the support of Win32-based applications and features, Windows 98 uses the 32-bit capabilities of the 80386 (and later) processor architecture to support a flat, linear memory model for 32-bit operating system functionality and Win32-based applications. A linear addressing model simplifies the development process for application vendors and removes the performance penalties imposed by the segmented memory architecture.

With this addressing model, Windows 98 allows full use of the 4 GB of addressable memory space for all 32-bit operating system components and applications. Each 32-bit application can access up to 2 GB of addressable memory space, enough to support the largest desktop application.

Support for MS-DOS Mode

Although most MS-DOS- based applications run well in Windows 98 and can run concurrently with other Win32-based and Win16-based applications, a small number of MS-DOS- based applications require exclusive access to system resources to run. The Virtual Memory Manager that creates for the application this exclusive operating environment, called MS-DOS Mode. When an MS-DOS-based application runs in MS-DOS Mode, no other applications or processes may compete for system resources — all resources are at the exclusive access of the MS-DOS- based application. For related information, see Chapter 25, "Application Support."