Exercise 1 - Memory Allocation
This exercise focuses on the DosAllocMem() function and its usage. The
sample program used in the exercise allocates and uses memory in order to
illustrate the new memory allocation mechanism, particularly with regard
to paged memory.
In this exercise, the student is required to run the program:
MEMLAB1.EXE
This program does the following:
Asks for an amount of memory to be allocated,
in integer-sized (4 byte) units.
Allocates and commits the requested amount of
memory.
Asks for the amount of memory to be used for
read/write operations. The amount of memory to be used is specified as the
number of integers to be written then read.
Performs writes to fill the requested amount
of memory.
Checks whether the written values are correct.
Frees the allocated memory.
At initiation the program registers two termination
routines:
a)
An abnormal termination routine, to which general
protection exceptions will be routed.
b)
A
termination routine, which is called when the program exits normally.
These
routines are used to print out the program status at termination and to
pinpoint where a general protection exception occurred. Note that C Set/2
routines are used to register the exception handler. DosSetExceptionHandler()
could also have been used.
The program will be executed three times during the course of the exercise.
The program listing is shown in Source
Code MEMLAB1.C.
[Back: Objectives]
[Next: Step 1 - Normal Memory Allocation]