INF: Windows: Nonpreemptive vs. Preemptive Scheduling

ID Number: Q11248

2.00 3.00

MS-DOS

Summary:

Preemptive scheduling, which Windows DOES NOT do, is defined in the

following way:

Between any two application instructions, N instructions may

execute in another application's context, where N is greater than

or equal to zero.

A nonpreemptive system, such as Windows, will guarantee that this

number N will always be zero.

In nonpreemptive scheduling, an application is not forced out of

context asynchronously (that is, it is not preempted). Instead, the

application runs until it explicitly gives up control. Windows-aware

applications give up control through various system calls. Although

they are not aware of it, DOS applications give up control whenever

they attempt various I/O functions.

DOS applications running under Windows 3.0 are in fact preemptively

multitasked. In contrast, all WINDOWS applications are nonpreemptively

multitasked. When the system is viewed from a Win386 perspective,

Windows runs in the system virtual machine (VM) and that VM competes

for time slices along with the rest of the DOS applications running in

other virtual machines. Keep in mind that unlike DOS applications, all

windows applications run inside the system VM, and are not given their

own virtual machine.

Note: An interrupt is not considered to be a form of preemption unless

there is an application context switch during the interrupt. An

interrupt takes the execution stream into the kernel, which returns

back to the same place without running another application, much in

the same way a call would.