Saturday, March 12, 2011

Windows is lousy at multitasking

So here I am burning a DVD. The DVD burn program is taking less than 5% of my CPU time, and yet my computer is so bogged down as to delay keyboard echo. (Keyboard echo is the printing on the monitor of each character struck on the keyboard). It is so bad as to make the my computer into a single task machine. Which is something of a waste.
Windows got this way from a design decision made way back at the beginning of Windows. Microsoft decided not to use the timer to give control to the operating system every tenth of a second. At the time they feared that interrupting the application programs 10 times a second would confuse them and cause crashes. They also feared that the operating system could fail if control passed from one program to another too rapidly.
These are fears of novice programmers. It is quite possible to write programs and operating systems that work reliably with a 10 per second timer interrupt. This was known at the time, various minicomputer operating systems (RSX-11 and VMS for two examples) used a timer interrupt and could give excellent performance to dozens of timesharing users simultaneously.
Microsoft decided to use "co-operative" multitasking instead. Each program is expected to return control to the operating system at frequent intervals. The reason it doesn't work is simple, there is always an application program that fails to play by the rules and hogs CPU time. There is nothing Windows can do about such a program, short of Ctl-Alt-Delete to kill it dead.
And it's too late to change it now. Doing so would undoubtedly break a bunch of programs and nobody wants to do that. This poor design decision was set in concrete and the concrete has hardened.

No comments: