INF: Large Model and Windows 3.0 Protected Mode

ID Number: Q79275

3.00

WINDOWS

Summary:

Large model applications can have more than one data segment. Windows

fixes the extra data segments of applications that have more than one

data segment even if they are declared MOVEABLE in the module

definition (DEF) file. Normally, these fixed data segments are movable

by Windows's memory manager in protected mode. However, there is a

problem, which causes fixed segments to be page locked, with the

Windows 3.0 memory manager. When a segment is page locked, the

physical memory associated with the segment becomes an obstacle for

the memory manager because the segment cannot be moved in physical

memory, nor can it be paged to disk. This behavior can have a serious

impact on system performance.

There are other issues to consider with respect to large model

applications. An application compiled with large model runs much

slower than an application compiled with medium or small model due to

FAR variables accesses. Large model applications use far pointer

arithmetic, which is generated by the compiler when the -AL compiler

switch is used, or when a far pointer is explicitly declared in the

application code.

Also, Windows cannot run more than one instance of an application that

has more than one data segment, because Windows's kernel cannot

presently resolve fix-ups to multiple data segments. For these

reasons, it is strongly recommended that Windows applications use only

small or medium memory model, which uses only one data segment.

More Information:

A large model application is limited to one instance because the

Windows kernel presently cannot resolve fix-ups to multiple data

segments. Consider the following code fragment that establishes DS:

mov ax, _data_01

mov ds, ax

This code is shared by all instances of the application. When the code

is loaded, only one value can be put into DS. Windows has no way to

"glue," or associate, other data segments to a given instance of the

application.

Windows's determination to allow only one instance is made when the

loader scans the EXE header of the application. Upon discovery of more

than one data segment, the application is limited to one instance.

In summary, there are three problems with applications compiled with

large model:

1. Large model applications use far pointer arithmetic, and thus will

run more slowly.

2. Large model applications that have more than one data segment will

have their extra data segments page locked by Windows and cause the

degradation of Windows's memory management.

3. Large model applications that have more than one data segment can

run only one instance.