Machine Problem V, due Apr. 9

Part of the homework for CS:3620, Spring 2018
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Begin with the version of heaptest.shar distributed to the class with this assignment. This is a test program for a heap manager, plus a very primitive heap manager that has been tested and actually works if you give it a sufficiently oversized heap. As distributed, the heap size is set one byte too small to force it to fail the test.

a) The heap manager distributed with this assignment does not merge free blocks, ever, so it suffers from severe external fragmentation.

Modify the code in xmalloc.c so that it merges free blocks. There are several ways to do this:

b) Experiment with your solution to part a) in order to find the minimum heap size that allows it to pass the test.

Configure your code with the defined constant HEAPSIZE set to this minimum.

c) All of your code must conform, as much as is possible, to the manual of style. The usual rules for comments apply, you must add your name as an author of any file you change, putting the most recent author first and never deleting names of other authors.

Make sure to update or delete any comments that are no-longer applicable to your version of the code! Clearly, if you fix a fault in the code, you should delete the comments that document that fault.

Try not to change parts of the code unnecessarily.

Your solution must be in a file named xmalloc.c (all lower case). Submit your solution using the coursework submission tools documented at:


In short, you will type the shell command submit, with no arguments, and when it prompts for a file name, you will type xmalloc.c. and then an extra carriage return to indicate that there is only one file in your submission. When it prompts for a course, type CS3620 and when it prompts for an assignment directory, enter mp5.

Note, file names on Unix/Linux systems are case sensitive! That includes the course name. If you type cs3620, it will not work. If you type CS:3620, it will not work.