[comp.sys.ibm.pc] Extended/Expanded Memory Question

valley@uchicago (Doug Dougherty) (03/24/91)

mcc@wlv.imsd.contel.com (Merton Campbell Crockett) writes:

>This will seem like a terribly naive question to many of you--it does to
>me; however, I would like to understand the difference between extended and
>expanded memory.

>I'm sure part of my problem in understanding the documentation provided with
>my 80286 (home) and 80486 (office) systems is my background.  I am and have
>been a systems programmer on NCR Century series, DECSystem 10, PDP11 series,
>and VAX series computers.  And, with the exception of NCR all have memory
>management hardware managed by the various operating systems that I've used.

>In this environment, programs can be loaded anywhere in physical memory but
>from the program's perspective it's address space always begins at location
>0 in its logical address space.  (For the nit pickers, thats not entirely
>correct but will suffice for this discussion.)  In writing device drivers,
>I simply remap the buffers involved into the device drivers address space
>and either use programmed I/O to transfer the data or set the devices hard-
>ware registers to access the physical memory associated with the logical
>memory address of the buffer for a DMA operation.

>Now, I have this 80486 system with 4 Mbytes of memory.  I have MS-DOS 4.01
>as an operating system but it only seems to know how to deal with the first
>640 Kbytes of memory and the "device" address space between 640K and 1M bytes.
>To support the various devices and a 210 Mbyte disk, MS-DOS seems to load
>a significant number of system programs in memory significantly reducing
>the 640Kbytes it knows about--to the extent I have programs complaining about
>insufficient space to perform some of their operations.

>Now with the memory management logic in the 80486 chip it seems that there
>should be no problem loading these extensions to the operating system into
>the memory above 1 Mbyte and have them execute from there.  Or for that,
>load a program anywhere that it will fit and let it execute from there.

>Now, given the above do I want extended or expanded memory?  One memory schema
>allows me to map memory in 64Kbyte windows but doesn't really allow me to
>execute code from that segment--or do I have that wrong?  Some application
>software contains logic to utilize memory above 1 Mbyte--do I have to check
>out each program and compute how much space it will utilize to install the
>memory management software?

>I'm sooooo confused!

It *is* confusing.  I've explained the whole schpiel a million times to
my co-workers, without ever really feeling that any of it took.

Just get QEMM and let it do the dirty work...

jayh@ms.uky.edu (Jay Hofacker) (03/24/91)

mcc@wlv.imsd.contel.com (Merton Campbell Crockett) writes:

>This will seem like a terribly naive question to many of you--it does to
>me; however, I would like to understand the difference between extended and
>expanded memory.

Extended memory is memory above 1 Mbyte that is directly accessable to an
80286/386/486 in 'protected mode'.  When theses chips first boot up they are
in 'real mode' which is completely compatible with the original 8088.  In real
mode there is 1 Mbyte of memory total, divided into 64K segments.  MS-DOS only
understands real mode, which is why it is limited to 1 Meg (640K because the
video buffer starts at 640K, and the addresses above that are used for ROMs).
In order to access extended memory, an extended memory driver must be used
to switches the chip into protected mode, retrieve the data requested, and
then swap back to real mode.  On 386 and 486 computers, it is possible for
software to map parts of extended memory into unused addresses above 640K.
Programs such as QEMM386 and 386 to the Max will let you load device driverss
and TSR programs into this remamped memory.

Expanded memory is memory which is access via a 64K window below 1 Meg.  In
order to access this memory, programs tell the expanded memory driver to swap
the desired 64K into the window, at which point the program can do what it
wants with it.  This memory can be available on any computer from an 8088 to
a 80486.

If you have a 386 or 486, I would suggest using extended ram with a memory
manager such as QEMM386.  QEMM will convert extended ram to expanded ram when
needed depending on what kind of memory programs ask for.
-- 
Jay Hofacker, sysop of the Audio/Visual Exchange, (606)254-1751 3/12/24 MNP 5
Mail: jayh@ms.uky.edu or uk02779@ukpr.uky.edu -- Yes, my signature is only 2 lin

edm@hpfcmdd.hp.com (Ed Moore) (03/27/91)

>I would like to understand the difference between extended and
>expanded memory.

Here's some stuff I've collected describing DOS memory management.  The
following article was taken from Algor Design World, April 1990.  Algor's
finite element analysis software for 80386 computers uses the Phar Lap DOS
Extender, as do AutoCAD 386, Paradox 386 and several other protected mode
programs. 
                        -------------------------------

Before the 80386, memory management was relatively easy.  DOS, written for the
8086/8088 processors, can directly use a maximum of 640K of RAM for the
operating system and application programs.  Later chips, such as the 80286,
were able to address more memory, but this memory could not directly be used by
DOS software because of the 640K maximum built into the DOS operating system.
The extra physical memory addressable by more powerful processors is called
Extended Memory, and was initially only used as RAM disks or for caching hard
disks.  However, as newer and more powerful programs were developed for DOS,
the 640K limitation for main memory became a bottleneck for some software
developers.

To address this situation, Lotus, Intel and Microsoft (LIM) created the LIM
Expanded Memory Specification (EMS).  This memory specification permitted
programs to access more than 640K of RAM by using a combination hardware-
software driver which "mapped" portions of the memory above 640K into the base
640K used by DOS programs.  This "swapping", done in 64K sections, lets DOS
programs move unused sections of program code or data in and out of higher
memory.  Additional memory in 80286 systems can be used as either Extended or
Expanded memory, while 8088 systems can only use Expanded memory.

The releases of the 80286 and 80386 microprocessors introduced several other
features which affected memory use under DOS.  With these processors, Intel
introduced the concept of "Protected" mode, where all of the physical memory on
the system is directly available to programs, regardless of the 640K limitation
imposed by DOS.  To insure compatibility with existing DOS software, Intel
preserved the standard 640K execution mode of DOS software (referred to as
"Real" mode), and introduced "Virtual 86" mode, where an 80386 running in full
Protected mode can run standard DOS programs by emulating an 8086 processor,
and can actually execute multiple real mode programs simultaneously if
controlled properly.  Finally, Intel also added the concept of "Paged Memory".
Paged memory means that the data contained in any segment of RAM can be
relocated to another address.  Therefore, on 80386 systems, the capabilities of
the LIM Expanded memory specification can be fully emulated in hardware through
paging from Extended memory.

The main advantage of the 80386 Protected mode are that programs written to
support this mode run much faster than standard DOS programs, and they can also
directly use all available memory.  Algor's Hyper software uses Protected mode
in solving larger problems by taking advantage of all the memory available on a
computer system.

Unfortunately, older programs, running in Virtual 86 mode or using EMS memory,
may require the use of a management program to let them execute in harmony with
Protected mode programs.  This is because the first program to switch the 80386
processor into Protected mode gets complete control of the processor.  Programs
subsequently run in Virtual 86 mode cannot get access to Protected mode unless
allowed to do so by the first program.

The need to negotiate between different programs for complete access to the
80386 and the need to emulate EMS for programs requiring this type of memory
led to the introduction of "memory management" programs.  These programs are
the first programs on an 80386 to execute in Protected mode, and handle
subsequent requests by intercepting signals within the computer system.
However, since the majority of software running on early 80386 systems was DOS
software running in Virtual 86 mode, some early memory management programs
inhibited the execution of other software in Protected mode because there was
no single standard governing how 80386 software requested and used Protected
mode.

The rapid expansion in the number of 80386 systems in use created the need for
a standard interface to Protected mode.  This standard, the Virtual Control
Program Interface (VCPI), was developed by Phar Lap Software and QuarterDeck
Office Systems, makers of 386 DOS|Extender and QEMM-386, respectively.  Other
memory management systems, such as Qualitas' 386MAX, also conform to the VCPI
standard.  Using these memory managers, 80386 Protected mode software
conforming to the VCPI standard can coexist with other conformant Protected
mode applications.  Algor's newest 386 software, written to run under Phar Lap
DOS|Extender, conforms to this specification.

                        -------------------------------

PC Magazine, 10/16/90, page 196, adds the following.

There are a variety of DOS applications designed to take advantage of the large
flat-address space capabilities of the 386 processor.  These applications rely
on built-in DOS extenders that take the 386 into protected mode.  Borland's
Paradox 386 database package is a good example.

Originally, all of these DOS extenders were incompatible with any program that
took the 386 into protected mode.  The Virtual Control Program Interface
(VCPI), initiated by Quarterdeck and Pharlap and finalized in June 1989,
provides a way for such programs to obtain the required flat-address space
without interfering with other protected mode programs.  VCPI allows
environments such as DESQview 386 and Omniview 386 to support Paradox 386 and
other applications that require the large flat-address space.

The chief drawback of VCPI is that it provides no protection between
applications.  There is nothing to prevent any application from crashing the
system -- DESQview 386, for example, might do it.  For these reasons, Vmos/3,
VM/386 and Windows do not support the VCPI.

The DOS Protected Mode Interface (DPMI), initiated by Microsoft with
contributions from other industry players, is intended to provide a way for
these applications to get the large flat-address space without crashing the
system if one application fails.  This interface is supported by Windows 3.0,
although it has not yet been finalized.  Therefore Windows supports Version 0.9
with the first formal version expected to be 1.0.

Over time, all 386-specific DOS applications should be adapted to run with all
386 DOS multitasking environments through some combination of VCPI and DPMI.
But for now you should check to ensure that your 386-specific applications are
compatible with the multitasking environment you choose.