Chapter 14

Windows 3.x

Objectives:

Review protected mode and learn how it relates to Windows 3.x

Understand virtual memory

Learn how to optimize Windows 3.x

Learn basic Windows troubleshooting

Graphical or Not?

DOS is a character-based operating system that does not come with a GUI.  DOS is further hampered by the fact it is designed to run on the Intel 8086 processor (real mode). If DOS is run on a 286 or better processor, the machine will not run at its full capacity, it will run as if it was an 8086 processor.

Generation of Microsoft Windows

Windows 3.0
Windows 3.1
Windows for Workgroups 3.1
Windows 3.11
Windows for Workgroups 3.11

The entire first generation of Windows is referred to as Windows 3.x, which still needs to run on top of DOS. The computer first boots to DOS, then you start Windows by typing the command WIN. 

By typing WIN will the Program Manager would start. Windows 3.x uses a special icon called a group into which icon pointers to programs are inserted.

Real Mode

Microsoft Windows was originally conceived as a DOS-based GUI. The first version of Windows did not have any memory-management functions and was not capable of multitasking. It was only for starting programs and managing files. This version of Windows ran in the 1 MB of RAM.  Later versions of Windows started moving outside of this limit.

Standard Mode

The first version of Windows to break out of the DOS 1MB barrier did so by engaging the 286-level protected mode. Windows could then address 16MB of RAM. Unfortunately, DOS programs were still limited to the 1MB memory barrier, so specialized programs had to be written to take advantage of extended memory. Because the programs could only run when Windows was active, Microsoft decided to expand the concept of Windows even further by adding support for standardized graphics, fonts, I/O devices, and memory mapping (all together known as resources). When windows broke the DOS barrier by engaging the 286 protected mode and began to take control of many hardware functions, Windows was said to be running in standard mode. 

One of the disadvantages to 286 protected mode was the inability to return easily to real mode. Remember DOS programs run only in real mode. For Windows to return to real mode, it would store 50K stub of data in conventional memory and reset the CPU, only the CPU was reset and everything else stayed the same. Therefore allowing the DOS program to be loaded.  In standard mode, Windows could only run one DOS program at a time.

Standard Mode was supported Windows up to Windows for Workgroups 3.11, when it was dropped in favor of the current mode: 386 enhanced. For Windows to operate in standard mode or 386 enhanced mode, the CONFIG.SYS file should have the HIMEM.SYS device driver loaded.

386 Enhanced Mode

Windows in 386's protected mode can address up to 4 GB of memory, support virtual memory, and allows multiple DOS programs to run simultaneously. 

Windows looks at everything in the computer as a selection of resources: memory, video, serial ports, sound, etc. All resources are presented to Windows through device drivers.  Almost all device drivers are stored in the \windows\system directory and almost always end with the extensions .DRV or .386.

Windows 3.x's core consists of three files: KRNL386.EXE, USER.EXE, and GDI.EXE. These three files are programs that allocate and keep track of all system resources requested by applications. They use a number of 64K storage areas of extended memory called heaps to keep track of which application is using which resource.

Resources are requested via standardized subroutines, called Application Programmers Interface (APIs). A program called speak directly to the Windows core through a special file called Dynamic Link Library, (DLL). A DLL acts as a storage house of subroutines that either come with the compiler that creates the application or are made by the programmer.

When a program starts in Windows, it first loads a small piece in conventional memory called a stub. The stub asks for RAM from KRNL386.EXE. The KRNL386.EXE allocates the amount of RAM needed by the application. This area of RAM is known as a segment and its location is stored in a heap. Once program is loaded, it starts asking for other resources, such as a mouse, video or anything else it will need to run. As long as there are resources to give, the Windows core will give them.

Swap Files

Windows 3.x runs in protected mode and can take advantage of virtual memory. Virtual Memory is an advance function of 386 protected mode that lets the CPU allow mass storage to act like RAM.  Virtual memory manifests itself through a special, hidden swap file, which is the part of the Hard Drive that thinks it is RAM.  Windows 3.x crates a swap file called 386SPART.PAR, which resides somewhere on your hard drive. The swap file is like temporary storage. Windows uses the swap file to remove running programs temporarily from RAM so other programs can be loaded and run.  A swap file is used only when you run out of RAM. A program cannot run actually run from the swap file. It must be reloaded back into RAM.  Even though there are no visual signs that programs are being "swapped" to and from RAM, you will notice a slowing down as the programs are being swapped.

Two types of Swap Files: Temporary and Permanent Swap Files.

Temporary swap files only exist while Windows is running. When you exit Windows, the temporary files are erased.

Permanent swap files are never erased. Permanent address files have the advantage of preaddressing every cluster within Windows. This is necessary for 32-bit file access to run. If you want 32-bit file access, you'll need a permanent swap file. When Windows is installed, you are automatically given a temporary swap file, so you'll have to make it permanent.

You will need to first exit to DOS and defrag the hard drive. When installing a permanent swap file, DOS tries to take 1/4 of the largest contiguous (defragment) part of the specified drive up to 25 MB.

Next you'll need to go to Virtual Memory Change Window. Pull down Type Menu under new Swap file settings and select Permanent.  Unless you have large files, 8 Megabytes of Permanent Swap files is enough. The swap-file size is inversely proportional to the amount of RAM. The more RAM you have the smaller the Swap File you need.

Initialization Files: .INI

Initialization files are text files with .INI extension used to initialize just about everything in Windows, from device drivers to Windows itself to applications. These files are stored in the \WINDOWS directory. These files are created by both Windows and Windows applications. 

An .INI file is editable through any text editor. Every .INI file is broken up into logical areas called groups. Each group starts with a word or words in square brackets called group header. Following each group header is the settings for that group. They are organized with the syntax item=settings.

There are two major setup screens that come with Windows, Control panel and Windows Setup.

List of common .INI files on Windows 3.x machines:

control.ini used to set colors and background patterns.
mouse.ini used to control mouse hardware settings.
progam.ini defines what groups are in the Program Manager and their relative positions. 
protocol.ini defines all the details necessary for the PC to exist on a network.
system.ini is the "Config.sys" of Windows.
win.ini is like the "Autoexec.bat" of Windows

SYSTEM.INI Groups and Settings:

[boot]
basic drivers needed by Windows

[boot.description]
contains text descriptions of the [boot] section.

[keyboard]
keyboard driver and a few optional settings

[386Enh]
the most important section of system.ini file.

32BitDiskAccess=On|Off
   
WIN /D:C allows you to start Windows without 32-bit disk access. 

ComXIrq=Number
   
allows you to set non default settings for you com ports

EMMExclude=XXXX-XXXX
   
anytime you have a x=XXXX-XXXX line in your EMM386 line in your config.sys file, you will also need an equivalent EMMExclude statement in
     the 386Enh section.  This is for excluding memory addresses.

EMMInclude=XXXX-XXXX
   
tells Windows where to include spaces it might not otherwise see.

MaxBPs=768
   
sets break points to help with GPFs. 

[NonWindowsApp]
contains information about DOS applications.

[vcache]
is a special 32-bit file access setting.

[mci]
contains media control interface drivers

[drivers]
generic driver names section. 

[network]
used with Windows for Workgroups only.

Win.ini

Load=
Run=

Configuring Windows

Using Disk Cache

SMARTDRV cache is taken from extended memory. Windows application also use extended memory. If there isn't enough RAM to load the programs , SMARTDRV can be counter-productive. Wincache tells windows how small it can shrink the SMARTDRV cache. 

SMARTDRV 1024 256

The 256 is called the Wincache. This tells Windows not to shrink the cache to less than 256K. You can set Wincache.  The CD-ROM driver must be loaded before SMARTDRV, otherwise it won't know there is a CD-ROM drive to cache.

Windows 3.11 and Windows for Workgroups 3.11 have VCACHE. (32-bit file access)

32-Bit Disk Access

32-Bit disk access (fast disk) is a fancy name for Windows skipping the BIOS on hard-drive accesses. Windows still needs to start a DOS session, but DOS talks directly to the Windows driver while in protected mode, eliminating some of the bottleneck. 

To engage 32-bit disk access, go to control panel and the 386 enhanced section. Access Virtual Memory and you'll see your current setup. Click on change. The next menu is for Windows 3.11 or Windows for Workgroups 3.11. You don't have the option for 32-bit file access with Windows 3.1.

32-Bit File Access

Again only in Windows for Workgroups 3.11.  With 32-bit file access, the DOS part of the hard drive access is intercepted by Windows, which means a DOS session--a Virtual Machine (VM) doesn't need to be opened whenever the drive is accessed. 32-bit file access is not hardware-sensitive and will often run even when 32-bit disk access won't. VFAT.386 

VCACHE is a superior protected-mode disk cache that replaces the relatively slow, real-mode SMARTDRV.  VCACHE is set roughly to 1/4 the available RAM, and unlike SMARTDRV, Vcache has no limits as to the total cache size. Vcache cannot cache a CD-ROM drive, therefore,  SMARTDRV is still necessary for machines using a CD-ROM drive in Windows 3.1.

Vcache is designed to work around SMARTDRV, even using the same cache space.

TEMP Files and RAM Drives

Many applications need to store data temporarily on the hard drive ending with .tmp extension. Temporary files are stored in one directory. It can be any directory and can be defined in the AUTOEXEC.BAT files. SET TEMP=path.  Every time a temp file is created, read, or erased, a hard-drive access is required. This is slow. You can install a RAM drive and tell the computer to save the temp files to the RAM drive instead of the hard drive. You'll need 16 MB or more of RAM.

In the config.sys file add the following statement:  device=c:\dos\ramdrive 1024.
In the autoexec.bat file add the following lines:      md E:\temp
                                                           SET TEMP=E:\TEMP

This will make a new drive letter, depending on the last drive letter and whether or not you've got a CD-ROM drive installed. All temp files will now be written to the RAM drive instead of the hard disk drive.

The disadvantage to this is creating a RAM drive takes up extended memory that Windows needs and many applications create very large TEMP files, requiring a very large RAM drive. If you create a RAM drive, it's best to make a RAM drive at least 4 MB, 8MB is better.

Memory Configuration

Memory Management is very important in Windows. Many GPFs, startup failures, and lockups are blamed on poor DOS memory management.

EMMExclude and EMMInclude:

if you have included or excluded any statements in your config.sys file, you will need to have the corresponding lines in your system.ini file.

example:  device=c:\dos\emm386.exe ram x=c800-c9ff x=da00-dd00 i=e000-e7ff   (config.sys file)

you will need to also have this in your [386Enh] section:

EMMExclude=c8000-c9ff
EMMExclude=da00-dd00
EMMInclude=e000-e7ff

Translation Buffers:

Windows needs UMB space for what are known as translation buffers. These are small storage areas of RAM that are used to support DOS applications and networks. If you are loading many devices into UMBs, add WIN= statement to the EMM386 line of your config.sys file.

device=c:\dos\emm386.exe RAM WIN=c800-c9ff

Printing Configuration

PIF files: Program Information Files.  If you run DOS applications in Windows, you should make a .pif. A pif is a binary file that tells Windows how to create a DOS virtual machine (VM). The PIF directs the amount of memory resource given to the DOS application. This memory resource is divided into video, conventional, expanded, and extended areas.  If you don't make a PIF for the DOS application a file will be provided for you _default.pif which is designed to create a VM that runs with as many DOS applications as possible. PIF has a PIF editor usually located in the Main directory.

Make a good PIF:

Program Filename: this is the name and path of the DOS program to run.

Windows Title: What program says at the top of the menu.

Optional Parameters: any switches you wish to run with program

Startup Directory: Where the file will startup.

Video: specifies the amount of memory reserved for video.

Memory Requirements: select smallest possible settings, check documentation.

EMS and XMS Memory: memory requirements for expanded and extended memory.

Display Usage: lets the DOS application run in a window or full screen.

Execution: background or exclusive options. Background runs program in background and exclusive means that when DOS application is in the foreground, everything else, including DOS and Windows, stops.

Close Window on Exit: checked by default.

Advanced: rarely used. (see pages 558-560)

Troubleshooting Windows 3.x

Lockups

GPFs

Erratics