Older Operating Systems

Class Notes # 17 Memory December 16, 2003

Memory Management Managing memory with Windows 9X is almost the same as with DOS and Windows 3.X. Memory is organized as conventional, upper, and extended as before. Windows 9X has made some improvements in , such as the allocation of memory and in the automation of the which makes it easier to manage memory for the user.

Windows 9X has replaced many old 16- device drivers with 32-bit device drivers. These 32-bit drivers are automatically loaded into . Therefore, this eliminates the need for DEVICE = entries in the CONFIG.SYS file. The new 32-bit drivers are sometimes called virtual device drivers or VxD drivers. These virtual device drivers operate in and have the .vxd or .386 file extensions.

Windows 9X can use the older 16-bit drivers, but it must provide a real-mode environment for these drivers to operate in. These 16-bit drivers are loaded by using entries in the CONFIG.SYS and AUTOEXEC.BAT files.

Windows 9X no longer uses SMARTDRV.EXE or SHARE.EXE. Recall, SMARTDRV.EXE is a disk caching program; a program that saves data in memory on the assumption that the same data will be used again. The SHARE program enables support for file and record locking. Windows 9X replaced SMARTDRV.EXE with a 32- bit disk caching file called VCACHE. Also, Windows 9X replaced SHARE.EXE with VSHARE.386, a part of VMM32.EXE that is automatically loaded when Windows starts.

Windows 9X uses HIMEM.SYS to manage extended memory just as DOS with the exception that HIMEM.SYS is loaded using IO.SYS and not the CONFIG.SYS file. Windows 9X uses 32-bit drivers and and therefore, there is no need to use the CONFIG.SYS file. Windows 9X is backward compatible with 16-bit drivers and software. When running DOS applications under Windows 9X, a DOS environment must be provided to the application. For example, to provide a DOS environment for the DOS program called EDIT.COM:

• Right click on the (located in \Windows\Command ) and select properties. • Click on the memory tab and you should see what is shown in figure one. • From the memory tab, you can specify how much conventional, expanded, and extended memory will be made available to this application. • The MS-DOS protected mode (DPMI) memory is used to assign the amount of protected mode memory allowed the application. If you check protected in the frame, Windows 9X will protect memory used by the system from the application.

1

Figure 1: memory setting for a DOS application (Edit.com)

Virtual Memory is using hard drive space so that it acts like RAM memory. Windows stores virtual memory in a file called a swap file. The purpose of virtual memory is to increase the amount of memory available. Virtual memory works at a considerable slower speed than real RAM memory. Virtual memory also uses hard drive space. For Windows 9X to use virtual memory, it must operate in protected mode. Recall, DOS only operate in . Windows 3.X uses 386 enhanced mode, which is protected mode and provides virtual memory to applications.

Windows 9X automates the managing of virtual memory. You can override the automation, but serves no purpose. The options that Windows 9X offers are shown by: • Opening the and select system and select the performance tab. The performance dialog box will appear as shown in figure two. • Click the virtual memory button and a dialog box will appear as shown in figure three.

The settings are used to tell Windows how to manage the swap file. You can specify the location of the swap file.

2

Figure 2: System properties dialog box

Figure 3: Virtual memory dialog box

3 Windows 9X provides virtual memory addresses to DOS and 16-bit Windows application programs by . The virtual memory manager manages memory paging.

Figure four illustrates how Windows 3.X manages memory where application programs share the memory addresses. For example, 64Mbytes of memory addresses are available. The 16-bit applications run in conventional memory, they might store their data in extended memory. Of the 64Mbytes of addresses, some addresses are assigned to RAM and some addresses are assigned to virtual memory contained in swap file on the hard drive. To the applications, there is only one set of memory addresses, and all application programs must share these addresses. Memory addresses 64Mb

Virtual memory Hard disk 640Kb

16-bit application Physical RAM memory 16-bit application

Figure 4: Windows 3.X memory management

Figure five illustrates how Windows 9X manages memory. Windows 9X not only has virtual memory stored in a swap file, but also provides virtual memory addresses to application programs. For example, in figure five you see three sets of virtual memory available. Each set contains 0 to 2Gbytes of addresses, depending on the amount of virtual memory available. Each virtual memory for DOS applications has their own set of virtual memory addresses. Each 32-bit program have their own set of addresses. The 16-bit Windows programs share a single set of virtual memory addresses.

In figure five, all virtual addresses map onto the table, which in turn maps onto either physical memory (RAM) or virtual memory on the hard drive (swap file). Not all virtual memory addresses in Windows 9X have physical or virtual memory assigned to them. These virtual addresses remain unassigned until an application program uses them.

The virtual memory manager controls the , moving 4kbyte pages in and out of physical memory (RAM). If a program requests memory that the memory manager knows is stored in the swap file, the manager generates a , which causes the manager to go to the drive to return the data from the swap file to RAM.

4 Virtual Memory Page addresses Table 2Gb

16-bit application

16-bit application 0 Virtual memory 2Gb Hard disk

DOS application Physical RAM memory

0

2Gb

32-bit application

0

Figure 5: Windows 9X memory mangement

Memory addresses A memory address is a number the CPU assigns to ROM or RAM, to locate any part of the memory. Therefore, both RAM and ROM must be assigned memory addresses so that the CPU can access this memory. Each memory address contains one of information. The number of address lines on the memory limits the amount of CPU memory addresses. For example, a CPU with 32 address lines can address up to 4Gbytes (232 = 4Gb) of memory. The CPU assigns memory addresses to RAM and ROM during the boot stage, and is sometimes called memory mapping. Figure six shows the memory assigned to the various devices during the boot sequence.

Typically, each components of a system is assigned a portion of RAM and that component is controlled through RAM memory. ROM, on the other hand, is not copied onto RAM. ROM only requires the CPU to assign it memory addresses. Therefore, the ROM programs become part of the total memory available and those programs are executed directly from ROM.

5 CPU assigned memory addresses

00000H Physical RAM 99999H

A0000H System BIOS BFFFFH (ROM)

C0000H Video card CFFFFH

D8000H Video RAM DF000H

F0000H Video ROM FFFFFH

Network card (Ethernet)

Figure 6: CPU assigns memory addresses during

6