Simons Blog | Newest post | About / Imprint

Why was Windows 3.1 almost unusable while accessing floppy disks?

Posted on: 2024-11-28

The first OS I used was MS-DOS in the early nineties. Soon the first usable versions of Windows came along. We had a test installation of Windows 3.0 on our 286 machine but no one really used it as it was way too slow and all the software was DOS based anyway. In 1994 we got our first 486 PC with Windows 3.1. Back then floppy disks were still common. Floppy disks are sloooow.

I remember every time I had to copy some large files around, the system would completely stall. I could Alt+Tab into a text editor but typing was barely possible until floppy disk accessed ceased. I've seen this as normal. It's just how floppies work. And in DOS you couldn't run multiple programs at once anyway, so there's that. But as soon as I got into systems programming, there was something I found out: First, accessing floppy disks is very light on the CPU. You just need to set a few controller registers, set up DMA (Direct Memory Access) and then the data is transferred to or from RAM automatically. If you don't have anything else to do, you need to wait until the transfer is complete. The BIOS provides a routine which does just that: Set everything up, initiate transfer and wait until it's done. It was used in DOS because there was nothing else to do anyway. But in Windows? It's multitasking, we could run other tasks while it's transferring! Why wait?

Indeed, in other operating systems, floppy disk access could happen flawlessly in the background. Later versions of Windows NT and of course all versions of Linux had no issues with this. You barely noticed the disk access in the background (except from the grinding noises of the stepper motors, of course).

I had some theories. Mainly it could be because Windows 3.1 was based on DOS and would simply use its filesystem access which is not made for multitasking? While that is true, later I realized that Windows 3.1 had 32-bit disk access which basically meant its own disk and Filesystem drivers. Completely independent from DOS. Why was it not used? Seems like a huge missed opportunity.

Before we get to, what I think, is the answer to this question, let's first analyze whether it even matters.

In the 80s it was common to see systems which had floppy disks as primary storage media. On better machines you had two drives, one for your application software, one for your data. If you had only one drive, you had to constantly swap disks. But then systems got bigger, programs more complex and at some point hard disks became mandatory. While theoretically you could run (a very crammed down version) of Windows from a floppy disk, no one actually did that. So all your programs and files lived on the hard disk. And while floppy disks used DMA to transfer data in the background, with hard disks, not so. Hard disk transfers to and from contemporary IDE disks happened in PIO (Programmed I/O) mode where the CPU had to process each individual byte as it came in and without waiting around or it would get lost or missed. The reason for that is that the DMA controller is very slow. It's fast enough for floppy disks, but hard disks at that time already outperformed it. (This was fixed with later DMA controllers in the naughties). I'm not sure how SCSI disks did that, but your typical desktop pc didn't have that anyway.

So what were floppy disks used for? Mainly backups and data transfer. Probably very few people worked with files directly on floppy disks, except maybe if they were coming from older systems and didn't want to adjust their workflow. So having to stop typing on that Word document while it was autosaving to a floppy disk, probably never happened. With saving to a harddisk, aside from a short stutter, typing was mostly uninterrupted.

And when copying large files to and from floppies, you typically had to wait around anyway. You needed to wait until that software package you were installing from multiple disks was finally installed, praying that you didn't hit a corrupted disk 10 floppies in. Also when backing up to multiple floppies, you had to swap them every 30 seconds or so anyway. Not much time to work on a document or spreadsheet in between.

Still, if other systems could to it so trivially, why didn't they optimize it? The problem lies in how Windows 3.1 multitasks. Most systems we use nowadays use something called pre-emptive multitasking. This means a program (rather, a Thread) can be interrupted at any point to have the CPU work on other Threads. This happens until they are interrupted themselves and time is given back to the original program, ideally without it noticing what just happened. On modern systems those switches can happen hundreds or thousands of times a second.

On all Windows versions before 95 and NT however, cooperative multitasking was used. Each program would get as much uninterrupted CPU time as it wanted, until it started processing messages by calling GetMessage() or a similar function. This gives control back to the system, scheduling other tasks until they called GetMessage() themselves. A program stuck in an endless loop could actually hang the whole system. So while this method was a lot more fragile, it also meant a lot less consumption of resources or synchronization overhead. Also notice that we are only talking about Single-CPU systems. multicore PCs were over a decade away.

So is a program calling GetMessage() when reading from disk? No, it's calling ReadFile() or WriteFile() to do disk I/O. No interruption point there, the system has to wait.