3.7 Memory Management Simulator
In C, simulate memory management.
Your program will receive no command-line arguments.
Your program should expect any number of simulations on standard input. When there are no more simulations, the program should exit without any other output.
A simulation is a setup line, any number of lines each containing one request, and finally a simulation ends with a line containing just q.
When the simulation ends, it should display q.
A setup line is a single line containing a policy and a memory size, separate by spaces. A policy is either first-fit (for a first-fit linked list), best-fit (for a best-fit linked list), or buddy (for a buddy system power-of-two block allocations with a minimum allocation of 32 bytes). A memory size is an ASCII encoding of a 32-bit unsigned integer to be used as the total size of memory.
When the simulator handles a setup line, it should re-display the line.
A request is a single line in one of two formats, either alloc or free. Each request has an index, numbered from 0, based on the order they appear in the simulation.
An alloc request has the form alloc SIZE where SIZE is the ASCII encoding of a 32-bit unsigned integer for the size of the allocation request.
When the simulator handles a alloc request, it should display alloc SIZE // INDEX ADDR FREE LARGEST where INDEX is the index of the request, ADDR is the address given provided by the simulator (-1 if it fails), FREE is the remaining free space, and LARGEST is the largest single free partition.
A free request has the form free INDEX where INDEX is the ASCII encoding of a 32-bit unsigned integer for the allocation request that is being freed.
When the simulator handles a free request, it should display free INDEX // FREE LARGEST where FREE is the remaining free space and LARGEST is the largest single free partition.
The program should have no other output.
A README file that contains a short write-up of your project. It should discuss the approach you took to solving the problem, it should discuss any problems or issues that still remain, it should discuss any interesting things that you learned in the course of the project. Finally, it should provide the grade you believe the project deserves with a detailed explanation of why. This explanation should almost certainly focus on why you believe the program is correct.
This file must be in plain-text. If you need formatting, use Markdown. It must be limited to 80 characters wide, unless you are quoting program output.
Your source code, named a5.c.
A test input file, named test.in, that contains example input. The input should have two simulations for each policy, in the order described above. The first simulation should have the memory size 512kb and the second should have the size 1mb. The smaller simulations should have 500 requests and the larger simulations should have 1000 requests. I highly recommend that you also produce much smaller test files during development.
A test output file, named test.out, that contains the expected output for the test data.
A Makefile that first builds the program and then tests it by running it with test.in as the input and compares the actual output to test.out.
This assignment will be graded based on its correctness and your ability to articulate why it is correct.