Search code examples
windowsmultitaskingwindows-server-2016esxi

NT10 Kernel preemptive multitasking


I am taking an Operating Systems course in which we work with Windows Server 2016 and ESXi

Our setup is one machine running W2K16 promoted to a DC, one running ESXi directly on the hardware and a client machine. On the ESXi machine we also have two additional virtualized copies of W2K16 one of which is promoted to a DC.

The question was posed how do you, using one of your machines, prove that the NT10 kernel uses preemptive multitasking rather than cooperative. Any help would be appreciated.


Solution

  • Write a simple program:

    volatile unsigned i = 0;
    
    int main() {
        for(; ; ++i);
        return 0;
    }
    

    Compile it, and launch as many copies as the CPU cores you have. Your computer won't lock up, you'll still be able to run other applications (although with degraded performance). This is a decent proof that you are running a preemptive multitasking OS.

    This program just wastes CPU cycles like mad, never explicitly or implicitly yielding the CPU back to the system; in a cooperative multitasking system, this would lead to a complete lockup of the system (once the task gets the CPU, it keeps it for itself, never leaving an opportunity to any other task to run).

    On the other hand, in a preemptive multitasking system you can keep yourself the CPU all you want, but the OS will regularly take it back (typically on some timer interrupt) to let other tasks run as well.