How real-mode Windows loaded code from the disk, and how you could use that to minimize disk swapping

Raymond Chen

Raymond

Real-mode Windows was originally designed to run on a PC with 192KB of RAM and two 360KB floppy drives. We saw some time ago that code was loaded dynamically off the disk on demand. The same principle also applies to read-only data, like resources.

Now, you might not have enough disk space on two floppies to hold the core operating system files, the program youā€™re trying to run, and your data files. No problem.

When Windows needed to load code from the disk, it searched the path for the module, opened it, read the necessary bytes from disk into memory, and then closed the file handle. This means that when the disk is not in active use, any floppy can be removed and swapped for a different floppy.

You typically organized your floppy disks like this:

  1. Windows system files.
  2. The program youā€™re trying to run.
  3. Your data files.

You started with Windows in drive A: and your data files in drive B:. Then you swapped your program disk into drive A: and ran your program. If Windows needed to access any system files, you swapped the Windows system floppy back in.

If youā€™ve been paying close attention, you may have noticed a sneaky optimization opportunity: If you have some extra room on floppy 2, you can put duplicate copies of popular system files on floppy 2, in a directory structure that matches floppy 1. Whenever Windows needs to access a file in order to load code from it, it searches the path. If you put a copy on both floppy 1 and floppy 2, then no matter which one you have in drive A:, Windows will find it and you wonā€™t be asked to swap disks. (If you were really crazy, you could add B: to your path and put some program files on your data disk.)

Or you could go and buy a hard drive. A 10 megabyte hard drive held the equivalent of 28 floppies and set you back around $700 (over $1500 in todayā€™s dollars).

Raymond Chen
Raymond Chen

Follow Raymond