Consider a memory management system using the First Fit algo
Consider a memory management system using the First Fit algorithm for memory allocation. That is, whenever a process needs to be allocated memory, the system will look for the first (lowest-addressed) free chunk of memory that is at least as large as the amount of memory needed by the process. When a free chunk is found, assume that the system allocates memory near the tail (higher-address end) of the free chunk for the process.
Let there be 192MB of space set aside, starting from address 64MB, to manage all the user processes in the system.
Let the following table depict the memory layout for a set of five processes in the system:
Now consider the following sequence of events in the system:
New process P6 starts and is allocated 28MB of memory.
New process P7 starts and is allocated 16MB of memory.
Process P2 terminates and releases its memory.
New process P8 starts and is allocated 16MB of memory.
Process P5 terminates and releases its memory.
New process P9 starts and is allocated 12MB of memory.
New process P10 starts and is allocated 4MB of memory.
Construct the memory layout after processing the above sequence of memory management events. Based on this layout, identify the TRUE statement among the following?
| Process | Memory Amount | Starting Location |
|---|---|---|
| P1 | 16MB | 72MB |
| P2 | 12MB | 88MB |
| P3 | 8MB | 124MB |
| P4 | 4MB | 132MB |
| P5 | 20MB | 166MB |
Solution
Ans:
Memory layout after the sequence of events mentioned above is as follows:
Note: The below memory layout is created taking in consideration that the system uses First Fit Algorithm for memory allocation.
FINAL MEMORY LAYOUT:
PROCESS MEMORY AMT STARTING LOCATION
P10 4MB 64MB
P1 16MB 72MB
P9 12MB 88MB
P7 16MB 100MB
P3 8MB 124MB
P4 4MB 132MB
P6 28MB 136MB
P8 16MB 186MB
HOLES AND THEIR LOCATIONS AT THE END OF SEQUENCE OF EVENTS:
Hole No. SIZE STARTING LOCATION
Hole1 4MB 68MB
Hole2 8MB 116MB
Hole3 22MB 164MB
Hole4 54MB 202MB
Hence,
a. Hole 1 has a size of 4MB and its the smallest free chunk hence a is TRUE.
b. The largest free chunk is between 202MB and 256MB and its 54MB in size, hence b is FALSE.
c. From TABLE-1 above, we can see that Process P7\'s memory allocation starts at 100MB, hence c is TRUE.
d. From TABLE-1 above, we can see that Process P9\'s memory allocation starts at 88MB and not 244MB, hence d is FALSE.

