The Windows 3.1 Virtual Machine

Tags

Much of the preemptive multitasking needed for Microsoft's forthcoming Chicago operating system (Windows 4) already exists inside Windows 3.1 Enhanced Mode.

The Windows 3.1 Virtual Machine Manager (VMM) that lives inside WIN386.EXE is missing features such as threads and mutexes, but it does have a fully preemptive time-slice scheduler, semaphores, lists of suspended processes, priorities, and many other features that you'd expect from a preemptive multitasking operating system. In fact, DOS386.EXE (which contains the VMM and many of the VxDs that make up the Chicago operating system) is an outgrowth of WIN386.EXE. 

One reason we tend not to think of Windows 3.1 as a full-blown multitasking operating system is that, ironically, Windows doesn't extend these capabilities to Windows applications. As Kelly Zytaruk notes in this month's "Undocumented Corner," the Windows kernel is a simple, non-preemptive multitasking operating system that runs as a single task within the larger Windows Enhanced Mode preemptive multitasking operating system.

But Windows Enhanced Mode doesn't preemptively multitask Windows applications; what, then, are the "tasks" that VMM manipulates? They're Virtual Machines (VMs). All Windows applications run in a single VM, called the "System VM." Each DOS Box is a separate VM. Thus, right now, all these preemptive multitasking facilities largely benefit DOS programs. Things will be different in Chicago, where the Win32 API provides threads, thread-synchronization facilities, and preemptive multitasking.

Since each task runs in its own separate VM, Windows multitasking is largely invisible to applications. Windows doesn't provide DOS and Windows applications with an API for communicating with other tasks, apart from a handful of calls such as INT 2Fh AX=1683h (Get Current VM ID) and AX=1685h (Switch VMs and CallBack) documented in the Windows Device Driver Kit (DDK).

Full Version


However, Windows 3.1 does extend a multitasking API to Virtual Device Drivers (VxDs). The DDK documents a set of scheduler services provided by VMM, such as Adjust_Exec_Priority, Begin_Critical_Section, Wait_Semaphore, Call_When_Task_Switched, Suspend_VM, Release_Time_Slice, Call_When_Idle, and so on.