This is only a preview of the September 1995 issue of Silicon Chip. You can view 34 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Articles in this series:
Articles in this series:
Items relevant to "Notes On The Train Detector For Model Railways":
Items relevant to "Build A Jacob's Ladder Display":
Articles in this series:
|
COMPUTER BITS
BY GREG SWAIN
Running MemMaker &
avoiding memory conf licts
Having trouble with General Protection Faults in
Windows? Try running the MemMaker memory
optimisation program. This will sometimes
overcome the problem and your programs will
run more efficiently too.
I remember seeing a movie some
time ago – a Western actually – in
which someone gets shot. “Who would
want to shoot Bad Bart?”, queried a
bystander after the bullets had stopped
flying and everyone had crawled
out from behind the bar. “Just about
everyone who ever knew him”, came
the reply.
What’s this got to computers and
memory? Well, in this case, the question is “Who’s encountered a General
Protection Fault when running Windows?” Answer: “just about everyone
who’s ever used it”.
OK, so it’s a bad analogy but you get
the general idea – General Protection
Faults in Windows are not uncommon. There you are working away
happily, running lots of applications,
when all of sudden up comes an error
message. Often, it will read something
like this: Progman caused a General
Protection Fault in module Filename
at 0001:0296.
Now isn’t that helpful? What this
means in plain English is that your
Windows application has written
to a memory space that was already
occupied, clobbering another module
(or file) in the process. As a result,
the system becomes unstable and the
wisest course is usually to exit all applications and reboot Windows.
Now there are lots of reasons why
GP faults can occur, including incompatible terminate-and-stay-resident
programs (TSRs) or device drivers in
your CONFIG.SYS and AUTOEXEC.
BAT files. In that case, you can often
troubleshoot the problem by removing
these TSRs – just type “REM: in front
of the appropriate entries.
If that solves the problem, you can
then proceed to replace the lines one
by one until the problem reappears.
When it does, you’ll know which one
is causing the GP fault.
Often, however, GP faults are caused
by other memory management problems. If you consistently get the same
error message when a certain function
is performed, then running MemMaker
may overcome (or at least minimise)
the problem.
EXTENDED
MEMORY
1024K
FFFF
UPPER MEMORY
AREA
384K
640K
A000
CONVENTIONAL
MEMORY
AREA
640K
Computer memory
Before we take a look at the Mem
Maker program, let’s first briefly look
at how memory is organised in a PC.
Fig.1 shows the memory configuration of a typical computer. The
first 640Kb is called “conventional”
memory and is used by all MS-DOS
programs. Above that but below 1Mb
is a 384Kb block called the “upper
memory area”. This block is normally
reserved for use by hardware expansion cards, such as your display adapt
er, and for shadowing video ROM and
the ROM BIOS.
Following the upper memory area,
the area beyond 1Mb is known as
“extended” memory. This memory
HIGH MEMORY AREA 64K
0K
0000
Fig.1: the memory configuration
in a PC. The first 640Kb is called
“conventional” memory, while the
area from 640Kb to 1024Kb (1Mb) is
the “upper memory area”. The area
beyond 1Mb is known as “extended”
memory.
requires the use of an extended
memory manager such as HIMEM.
SYS and this device driver is typically loaded as the first line in your
CONFIG.SYS file.
Finally, the first 64Kb of extended memory is known as the “high
September 1995 57
drivers and programs.
On the other hand, if you run a
DOS-based program that does require
expanded memory, you will have to
replace the NOEMS switch with the
RAM switch instead. This will allow
EMM386.EXE to simulate expanded
memory so that the program will run.
For example, the command:
DEVICE=C:\DOS\EMM386.EXE 512 RAM
By typing mem /c/p at the DOS prompt, you can see which programs are loaded
into conventional memory and which are loaded into upper memory. It will also
tell you how much free conventional memory you have and whether or not MSDOS is resident in the high memory area.
memory area” (HMA). Usually, MSDOS is set to run in the HMA, to free
up conventional memory for use by
other programs.
To see how your computer currently
organises memory, exit Windows and
type mem /c/p at the DOS prompt. This
will show you which programs are
loaded into conventional memory and
which are loaded into upper memory.
It does this by displaying a detailed
listing of the load order and size of
these programs – see Fig.2.
It will also tell you how much free
memory you have, the largest executable program size and whether or
not MS-DOS is resident in the high
memory area.
What MemMaker does
Because the hardware expansion
cards do not use up the entire upper
memory area, it contains free areas of
space and these are known as “upper
memory blocks” (UMBs). When you
run MemMaker, it modifies your AUTOEXEC.BAT and CONFIG.SYS files
so that some TSRs and device drivers
are loaded into these UMBs instead of
into conventional memory.
As a result, conventional memory
is freed and this can make a big difference to the way your programs run.
58 Silicon Chip
If you’ve already run MemMaker and
subsequently installed additional software, it can also help to avoid memory
management conflicts be reallocating
space in the upper memory blocks.
By the way, in order to load programs into the upper memory blocks,
you must use an expanded memory
manager such as EMM386.EXE. Depending on the entry in your CONFIG.
SYS file, this device driver can also
use extended memory to simulate expanded memory for those DOS-based
programs that require it.
Typically, the first three lines of
CONFIG.SYS will look like this:
DEVICE=C:\DOS\HIMEM.SYS
DEVICE=C:\DOS\EMM386.EXE NOEMS
DOS=HIGH,UMB
Note that it is necessary to load
HIMEM.SYS before EMM386.EXE to
gain access to the upper memory
blocks. The NOEMS switch ensures
that EMM386.EXE behaves as an upper
memory manager only and prevents
it from allocating extended memory
(EMS) for use as expanded memory
(XMS). Use this switch if your programs do not require expanded memory, as this frees an additional 64Kb
of upper memory for running device
will allocate 512Kb of your computer’s
extended memory for use as expanded
memory. Note that you should only
allocate as much expanded memory
as the program requires and this will
usually be specified in the installation
manual.
If the command line that loads
EMM386.EXE is missing, it can easily
be added by editing the CONFIG.SYS
file in an ASCII text editor. Alternatively, the MemMaker program will
automatically install and configure
EMM386.EXE for you.
Start-up disc
Before running MemMaker, it’s
vital that you create a start-up disc in
case anything goes wrong. To do this,
install an unformatted floppy disc in
drive A and type: FORMAT A:/S. This
done, copy your AUTOEXEC.BAT and
CONFIG.SYS files (and preferably your
SYSTEM.INI file in the Windows directory) to the floppy disc.
That way, if anything goes wrong,
you can boot from the start up disc
and simply copy the original files
over the top of the modified files on
the hard disc.
It’s also a good idea to disable any
commands in your AUTOEXEC.BAT
and CONFIG.SYS files that start unnecessary device drivers and utility
programs. This will help to free up
conven
tional memory by ensuring
that such programs do not compete for
space in upper memory. For example,
if you only use a mouse when running
Windows, then you can disable any
mouse device drivers such as MOUSE.
COM.
To disable a command, simply
open the file in an ASCII text editor
(eg, DOS Edit or Notepad) and insert
a REM statement at the beginning of
the command line, eg:
REM DEVICE =C:\DOS\MOUSE.
This done, save the file and then
reboot the computer. By disabling the
command in this manner, rather than
deleting the line, you can easily restore
it later on if required.
Running MemMaker
MemMaker is supplied with MSDOS 6.0 and above and is straightforward to run – just quit all programs, go
to the command prompt (ie, C:>) and
type Memmaker. All you have to do
then is follow the on-screen prompts
or the step-by-step procedure set out
in the manual.
Unless you are an experienced
user, it’s best to choose Express Setup
(as opposed to Custom Setup) when
running MemMaker for the first time.
You should also initially answer “No”
to the prompt that asks you whether
you use any programs that require
expanded memory, unless you are sure
that the reverse is true.
If you choose No and subsequently
find that some programs no longer
run or display error messages (eg,
“Expanded Memory Unavailable”),
then its simply a matter of running
MemMaker again and answering “Yes”
to the same question.
After you have finished running
MemMaker, take a look at your CONFIG.SYS and AUTOEXEC.BAT files.
In CONFIG.SYS, you will see that
MemMaker has changed certain “device” commands to “devicehigh” and
added switches to those “devicehigh”
commands. Similarly, in AUTOEXEC.
BAT, you will find that MemMaker has
added “lh” (loadhigh) to the beginning
certain commands.
These “devicehigh” and “lh”
commands ensure that the corre
sponding device drivers and TSRs are
loaded into the upper memory area.
Note, however, that HIMEM.SYS and
EMM386.EXE cannot be loaded high.
Now for the acid test – to find out
AUTOEXEC.BAT
Before MemMaker
<at>ECHO OFF
VERIFY OFF
PATH C:\DOS;C:\WINDOWS;C:\ALDUS;C:\PM5;C:\UTIL;
C:\DESKSCAN;C:\TSCSI;
SET TEMP=C:\TEMP
SET DIRCMD=/P/O
PROMPT $P$G
C:\DOS\MOUSE
C:\DOS\MSCDEX.EXE /D:PANASON /L:R
C:\DOS\DOSKEY
VER
WIN
After MemMaker
<at>ECHO OFF
VERIFY OFF
PATH C:\DOS;C:\WINDOWS;C:\ALDUS;C:\PM5;C:\UTIL;
C:\DESKSCAN;C:\TSCSI;
SET TEMP=C:\TEMP
SET DIRCMD=/P/O
PROMPT $P$G
LH /L:3,56928 C:\DOS\MOUSE
LH /L:3,27984 C:\DOS\MSCDEX.EXE /D:PANASON /L:R
LH /L:2,6400 C:\DOS\DOSKEY
VER
WIN
Fig.3 (above): a typical AUTOEXEC.BAT file before and
after running MemMaker. MemMaker has added “LH”
commands to the start of several lines, to ensure that
these TSRs are loaded into the upper memory blocks.
Fig.4 (right): devices are loaded into the upper memory
blocks using the DEVICEHIGH command. Note, however,
that HIMEM.SYS and EMM386.EXE cannot be loaded
high.
what effect MemMaker has had on
your system, go to the command
prompt and again type mem /c/p. You
should see that many (if not all) of
the available device drivers and TSRs
are now loaded into upper memory
instead of conventional memory. In
addition, you should have a corre
sponding increase in conventional
memory.
Fig.3 shows a typical AUTOEXEC.
BAT file before and after running
MemMaker, while Fig.4 shows typical
before and after CONFIG.SYS files.
If you encounter problems after
running MemMaker, you can easily
undo the changes that have been
made. To do this, you simply go to the
command prompt (ie, C:\>) and type:
Memmaker /undo. By then following
the on-screen prompts, the program
will restore the original AUTOEXEC.
BAT, CONFIG.SYS and SYSTEM.INI
files, using backups that it made during
CONFIG.SYS
Before MemMaker
DEVICE=C:\DOS\HIMEM.SYS
DEVICE=C:\DOS\EMM386.EXE NOEMS X=C800-CBFF
BUFFERS=30,0
FILES=60
DOS=HIGH,UMB
LASTDRIVE=Z
FCBS=4,0
DEVICE=C:\TSCSI\MA348.SYS
DEVICE=C:\TSCSI\TSCSI.SYS
DEVICE=C:\CDMKE.SYS /D:PANASON
DEVICE=C:\DOS\SETVER.EXE
DEVICE=C:\DESKSCAN\SJII.SYS
BREAK=ON
COUNTRY=61,,C:\DOS\COUNTRY.SYS
SHELL=C:\DOS\COMMAND.COM C:\DOS\ /E:1024 /p
STACKS=9,256
After MemMaker
DEVICE=C:\DOS\HIMEM.SYS
DEVICE=C:\DOS\EMM386.EXE NOEMS X=C800-CBFF
BUFFERS=30,0
FILES=60
DOS=HIGH,UMB
LASTDRIVE=Z
FCBS=4,0
DEVICEHIGH /L:2,9568 =C:\TSCSI\MA348.SYS
DEVICEHIGH /L:2,15488 =C:\TSCSI\TSCSI.SYS
DEVICEHIGH /L:2,13472 =C:\CDMKE.SYS /D:PANASON
DEVICEHIGH /L:2,12048 =C:\DOS\SETVER.EXE
DEVICEHIGH /L:1,7040 =C:\DESKSCAN\SJII.SYS
BREAK=ON
COUNTRY=61,,C:\DOS\COUNTRY.SYS
SHELL=C:\DOS\COMMAND.COM C:\DOS\ /E:1024 /p
STACKS=9,256
September 1995 59
Fig.6: this detailed
map shows the
upper memory area
from A000-FFFF.
The gray areas are
treated as ROM and
are reserved for the
video card (C000C7FF) and the ROM
BIOS (F000-FFFF).
The areas marked
with “U” indicated
used UMBs, while
“F” indicates free
UMBs.
the optimisation process.
Alternatively, if you suspect that the
problem might be caused by one or
more commands in AUTOEXEC.BAT
or CONFIG.SYS, you can bypas some
or all of the commands in these files
(MS-DOS 6.0 and above).
To bypass all the commands in
these two files, press the F5 key when
you see the text “Starting MS-DOS . .
.” while the computer is booting up.
Alternatively, to bypass individual
commands, press the F8 key instead
and follow the on-screen prompts to
carry out or bypass each command
in turn.
The Memmaker.sts file
That’s not necessarily the end of the
memory optimisation process. Often,
you can free up even more memory by
changing the order of the command
lines in your CONFIG.SYS and AUTOEXEC.BAT files.
The reason for this is that as each
driver is loaded in turn into the upper
memory area, it uses the largest free
remaining UMB. This means that if
the smaller drivers are loaded first,
the remaining UMBs might not be able
to accommodate some of the larger
drivers.
In this case, these remaining large
device drivers will be loaded into
60 Silicon Chip
conventional memory rather than
upper memory, despite the presence
of “devicehigh” or “lh” commands.
The trick is to reorganise your CONFIG.SYS and AUTOEXEC.BAT files
so that the largest device drivers are
loaded first. That way, it will be easier
to fit the remaining drivers into the
smaller UMBs that are left over.
How do you know the sizes of your
device drivers? Well, when you run
MemMaker for the first time, it logs
this information in a file called MEMMAKER.STS (in the C:\DOS directory).
Open this file in an ASCII text editor (or
better still print it out) and make a note
of the MaxSize line for each command
in the [SizeData] section – see Fig.5.
It’s now simply a matter of editing
the CONFIG.SYS and AUTOEXEC.BAT
files so that those command lines with
larger MaxFile values are positioned
Command=C:\DOS\SETVER.EXE
Line=11
FinalSize=864
MaxSize=12048
FinalUpperSizes=0
MaxUpperSizes=0
ProgramType=DEVICE
Fig.5: a typical section from a
MEMMAKER.STS file. The MaxSize value is the one to note.
above those with smaller MaxFile values (make sure that HIMEM.SYS and
EMM386.EXE are before any of these,
however). Save each file in turn, then
reboot your computer to check that
the system starts properly and that
there are no error messages during
start-up. If all is well, run MemMaker
again to optimise the system for the
revised CONFIG.SYS and AUTOEXEC.
BAT files.
By now typing mem /c/p at the command prompt again, you can quickly
check how much more conventional
memory has been freed.
Note, however, that the above
procedure is not always hassle free.
Sometimes, for example, it is necessary to load the drivers for a particular device in a set order (where
more than one driver is involved). If
the order is incorrect, you will get an
error message during boot-up, often
to the effect that a particular driver is
missing. In that case, it’s usually just
a matter of moving the command line
for the “missing” driver ahead of its
companion driver.
Fig.4 shows an example of this. If
you look at this file, you will see that
the line
DEVICEHIGH /L:2,9568 =C:\TSCSI\MA348.SYS
precedes the line
DEVICEHIGH /L:2,15488 =C:\TSCSI\TSCSI.SYS
even though the second line has the
largest MaxSize value. That’s because
it’s necessary to load MA348.SYS
before TSCSI.SYS for this particular
device (an external cartridge drive).
Fine tuning
Now take a look at the detailed
memory map of Fig.6. One important
thing to realise here is that not all
addresses in the upper memory area
are available for loading device drivers
and TSRs. For example, the area from
A000-C800 is reserved as ROM for
video card addresses, while the area
from F000-FFFF is reserved for shadowing the ROM BIOS. Similarly, the
area from E000-EFFF is also normally
a reserved area.
What this means is that these ranges
are out of bounds for use as UMBs unless you specifically instruct EMM386.
EXE to include certain areas within
them (ie, EMM386.EXE does not map
over unused ROM). This is done using
the I= switch.
For example, if your computer has a
VGA or EGA monitor, you can generally include the range of address from
B000-B7FF and from E000-EFFF. In
this case, the EMM386 entry in your
CONFIG.SYS file would look something like this:
Exploring the Memory with MSD
1. To see how
memory is allocated in your machine, go to the
DOS prompt and
type MSD. The
screen shown at
left will appear.
Click on Memory.
DEVICE=C:\DOS\EMM386.EXE I=E000-EFFF
I=B000-B7FF NOEMS
If you subsequently find that your
monitor doesn’t respond correctly or
your computer hangs when you start
Windows, delete the I=B000-B7FF
entry. If you still have problems, delete
the I=E000-EFFF statement
On the other hand, it is also often
necessary to specifically exclude certain address ranges to prevent memory
conflicts with hardware cards. If this is
not done, a device driver can be loaded
into the address normally occupied
by the hardware card and this will
prevent the card from being found.
For example, let’s say that you have
a hardware card (eg, a scanner card)
at address C800. In this case, you
might want to exclude the range from
C800-CBFF and this is done using the
X= switch, ie:
2. The resulting
screen shows
free (F) and
used (U) UMBs,
plus areas
which are reserved as ROM.
Click the down
arrow to see
the area below
C000.
3. Clicking
“Utilities” and
then “Memory
Block Display”
brings up this
screen. You can
now examine the
memory allocated
to each driver by
clicking on it
(in this case,
SMARTDRV.EXE).
DEVICE=C:\DOS\EMM386.EXE I=E000-EFFF
I=B000-B7FF NOEMS X=C800-CBFF
Note that MemMaker will normally
automatically exclude the address
ranges occupied by hardware cards
the first time you run it. If you subsequently install another hardware card
and you strike problems, try changing the address setting on the card.
Alternatively, you can work through
the section entitled “You Installed A
Hardware Device And Your Computer
Stopped Working” in chapter 8 of the
MS-DOS 6 manual.
By the way, it’s also a good idea to
edit the Emmexclude= entry in SYSTEM.INI, to prevent Windows from
accessing this address range when
running in Enhanced mode – ie, add
the line Emmexclude=C800-CBFF to
the [386Enh] section of SYSTEM.INI.
In addition, some video cards use
additional memory in the region
from C400-C700. Although Windows
automatically detects most of these
cards and avoids this area, there are
cases where you have to specifically
exclude it using the Emmexclude
entry. For example, to avoid the area
from C400-C7FF (to prevent conflict
with a video card) and from C800-CBFF to prevent conflict with another
hardware card, the line would read:
Emmexclude=C400-CBFF.
If you are still having trouble running Windows in enhanced mode (eg
if the system frequently crashes), try
starting Windows using the “/d:x”
switch – ie, type win /d:x at the
command prompt. This will prevent
Windows from accessing any of the
upper memory area and is equivalent
to adding Emmexclude=A000-EFFF
to SYSTEM.INI.
If this solves the problem it means
that there is a conflict with some hardware card that Windows is unable to
detect. To solve this problem, you need
to identify which hardware card is
causing the problem and then exclude
its address with Emmexclude. To find
out the address, check the address
switches on the card or use the Micro
soft Diagnostics program MSD.EXE .
Try to limit the excluded the range
to the specific card. If Windows is
unable to find enough free UMBs for
what are called “translation buffers”
when it loads, it uses conventional
memory instead. As a result, there
will be less memory available to run
non-Windows applications.
Finally, if it’s all too hard, consider
upgrading to Windows 95. With this
system, the old DOS/Windows combination is gone and you don’t have
to worry about tweaking AUTOEXEC.
BAT, CONFIG.SYS and SYSTEM.INI
files. Is your computer up to Windows
95? Here we go again!
SC
September 1995 61
|