MEM_alloc
Application Program Interface
2-217
memory block has a size of 0x8000, and is large enough for this
allocation. So, P1 points to a block from 4:2000 to 4:7FFF.
❏
P2 = MEM_alloc(MYSEG, 0x1800, 0);
This call requests 0x1800 words. Blocks 1 and 2 are again too small.
The last block has 0x2000 words remaining, and can accommodate
this allocation. So, P2 points to a block from 4:0800 to 4:1FFF.
❏
P4 = MEM_alloc(MYSEG, 0x800, 0);
This call requests 0x800 words. This time, the first block is large
enough. So, P4 points to a block from 2:F800 to 2:FFFF.
Consider how this memory map would change if the same MEM_alloc
calls were made in the following sequence:
P1 = MEM_alloc(MYSEG, 0x6000, 0);
P2 = MEM_alloc(MYSEG, 0x1800, 0);
P3 = MEM_alloc(MYSEG, 0xFF80, 0);
P4 = MEM_alloc(MYSEG, 0x800, 0);
The results of this modified call sequence are as follows and are shown
in Figure 2-3.
Figure 2-3.
MYSEG Memory Map After Modified Allocation
❏
P1 is allocated from 3:A000 to 3:FFFF.
2:F800
2:F000
3:0000
3:FFFF
4:0000
4:7FFF
3:8800
3:A000
2:FFFF
P3
P4
0x0800
No Space
for P3
(0xFF80)
0x1800
0x6000
P2
P1