• Aucun résultat trouvé

CODE-MAPPING UNDER VENIX

Dans le document PRO/VENIXTM for (Page 162-167)

4.1 INTRODUCTION

Code-mapping is a memory overlaying scheme for expanding the address space available to programs. It requires no source-code modification, and thus is entirely transparent to the programmer. However, since code-mapping does slow program execution somewhat, it is recommended only for programs whose size absolutely requires it.

4.2 DESCRIPTION

Program address space is divided into two parts: the code (or text) space, con-taining the program instructions, and the data space, concon-taining the values on which the instructions operate. While PDP-ll computers may be configured with large amounts of memory (often 512kb or more), the address space allowed any individual program is ordinarily much less. Code-mapping allows a pro-gram easy access to the memory which would otherwise be out of bounds.

Code-mapping is currently implemented only for non-split liD, machines such as the DEC Professional and other LSI-11123 computers, the PDP-11124, 111 34, and 11160. On these machines, the maximum program size is ordinarily at most 64 kilobytes (kb). (As discussed later, the 8kb always reserved for the stack brings the effective program size down to 56kb). If code-mapping is used, however, the code portion of the program can become very large, and is limited only by the amount of memory physically on the computer. The data space remains restricted to 48kb.

CODE-MAPPING UNDER VENIX

Code-mapping works by dynamically mapping 8kb segments of the program's code in and out of the standard 64kb address space. At any given time, a sin-gle 8kb segment of the program code will be mapped in and available for execu-tion, while all the other 8kb segments of code are mapped out of the 64kb address space. In addition to the mapped segments, there is a single "resident"

8kb segment which is not mapped but instead maintained permanently inside the 64kb space.

The mapping is done entirely with PDP-ll memory management hardware.

Unlike some other overlaying schemes, code-mapping does not copy program segments to disk.

4.3 WHEN TO USE CODE-MAPPING

There are two circumstances in which a user may require code-mapping. First, a given program may simply be too large to load into memory. When the user tries to execute it, the shell immediately responds with:

a.out: too big or

a.out: Not enough core

depending upon which shell is being used. At this point, the size(1) command can be run on the user's program. The result might look like this:

size a.out

44278 + 14466 + 12244 = 70988b = 0212514b

The first number given (44278) is the code space in bytes; the second two num-bers (14466 + 12244) make up the data space. The total program size is given in decimal (70988b) and then in octal (0212514).

For a program to run without code-mapping, the total size, as reported by size, must be less than or equal to 56kb: (57344 bytes decimal, or 0160000 octal).

The reason that this limit is not the full 64kb, is that size does not report the 8kb segment at the top of the address space which is always reserved for the stack. The size of the above program was greater than 56kb, thus code-mapping is required.

CODE-MAPPING UNDER VENIX

A second circumstance requmng code-mapping occurs when a program meets the 56kb limit described above, but runs out of memory while executing. This

Memory usage of sample program before mapping:

00-43kb

Memory usage of program after code-mapping:

00-08kb

CODE-MAPPING UNDER VENIX

cc -c -m file1.c file2.c file3.c cc -m - 0 prog

Note that in the latter case the -m flag was used both times that cc was exe-cuted.

In the example above, the cc command automatically passed the - m flag on to the loader (ld(l» to indicate that code-mapping was desired.

4.5 SPECIAL CASE ROUTINES

There are certain cases in which the loader must be called directly. These occur if the program uses

1. printfO routines called with double or float type data 2. signalO calls

3. floating point simulation (machine has no floating-point hardware)

Each of these cases requires that the loader be called directly, in order to force certain routines to be placed in the "resident" portion of code space. This is done by passing a -u flag to the loader, to force certain routines to be immedi-ately considered "unresolved", and thus loaded in first.

The loader command line should be of the following form:

Id - X - u f1 - u f2 ... - m llibl crtO.o filel.o file2.0 file3.0-1e

where 11, 12, etc., are the names of critical symbols which must be loaded first and kept resident. In the case of printfO calls using double or floating types, the symbols to use are _doprnt and fltused, as in

Id -X -u _doprnt -u fUused [-u ... J -m llib/crtO.o ....

If signalO is used, the symbol to pass is ~ignal, as in Id -X -u ~ignal [-u ...

J

-m llib/crtO.o ...

CODE-MAPPING UNDER VENIX Finally, if floating point simulation is used, the following command should be used:

ld - X - u fptrap [-u ..•

J -

m -Ifpsim llib/fcrtO.o ....

Note that the floating-point simulator start-off llib/fcrtO.o was used above instead of llib/crtO.o. The -u options can be combined if the program falls under more than one of the above categories.

4.5.1 Code-Mapping Fortran Programs

The loader must also be called directly when linking Fortran programs. Fortran modules may be compiled to object form with the command:

f77 - c file 1. 0 file2.o ....

and the linked form with code-mapping using the command:

ld -X -m Ilib/crtO.o file1.o file2.o .... -IF77 -1177 -1m -Ie

4.6

LIMITATIONS

AND NOTES

The following is a summary of code-mapping limitations:

• The maximum size of a single object module (.0) is 8kb.

• The maximum available data space is 48kb.

• The maximum available code space is determined by the amount of physi-cal memory minus kernel size (48kb) minus the program's data size.

• The maximum number of functions in code-mapped space is -1500.

• The code of a code-mapped program is automatically shared if the pro-gram is run by more than one user. This saves on the amount of physical memory being used.

Dans le document PRO/VENIXTM for (Page 162-167)