What you will learn:
Issues in memory management
Assignment
Write a memory allocator simulator that implements following memory allocation scheme:
The calling processes requests
memory chunks of needed sizes.
The returned chunk is
treated as contigous by the process (logical addresses),
but they may be physically distributed/scattered
in main memory.
The process may
free an allocated chunk.
The above has been expressed in terms of a few system calls
as below.
(1) void initialize
(int x)
- creates x bytes of free main memory
from which further allocate/free requests are to be handled
(2) int alloc
(int x)
- allocates x bytes and returns the
starting logical address to the caller
(3) void printPhysicalDistribution
()
- prints the physical distribution of the various logical segments
(4) void free
(int logicalstartaddress)
- frees the chunk identified by the
start logical address
Assume that logical address always monotonically increase
Your program should provide a command prompt to accept any sequence of the
above commands one by one like
an interpreter. The commands are to be abbreviated as follows:
(command 1 shortform) i 100
(command 2,3 and 4) a 20
p
f 0
Test your 4 functions on a few test cases. A sample test
request pattern
files are provided in this directory
What to submit
your single C program + readme that analyzes
your scheme
Donot submit your binaries, executables. Your marks will be reduced if you do so.
Some Pointers
You can use fopen, fopen, fclose, fscanf etc for file i/o.
Submission
Assignment no=10.
Submit your file using ~oslab/submit script as in: ~oslab/submit 10 xyz.c
submit script accepts assignment no. in its first argument. Any number of
files may be submitted through subsequent arguments.
You may submit any number of times before 5:00pm. Old files are overwritten
in resubmission.
Deadline: 5:00pm
Enjoy.