Project #8: Heap Memory

Submit: Turn in your entire xinu-hw8 directory source files using the turnin command on morbius.mscsnet.mu.edu or one of the other Systems Lab machines. Please run "make clean" in the compile/ subdirectory just before submission to reduce unnecessary space consumption.

Work should be completed in pairs. Be certain to include both names in the comment block at the top of all source code files, with a TA-BOT:MAILTO comment line including any addresses that should automatically receive results. It would be courteous to confirm with your partner when submitting the assignment.

Dynamic Memory Allocation

Preparation

First, make a fresh copy of your work thus far.
      cp -R xinu-hw7 xinu-hw8

Then, untar the new project files on top of it:
      tar xvzf ~brylow/os/Projects/xinu-hw8.tgz

Be certain to make clean before compiling for the first time.

Getmem and Freemem

The files include/memory.h and system/vm_userinit.c define and initialize a free lists of available memory blocks on the heap. Implement system/getmem.c and system/freemem.c to dole out blocks of requested memory and properly maintain the free list. Use First Fit with simple compaction. (Compaction is the "stretch" problem in this assignment -- get everything else working first.)

Malloc and Free

Your getmem() and freemem() functions assume that the programmer independently tracks the size of an allocated block, and passes that size as the second parameter to freemem(). Most operating systems APIs assume that having the pointer to the beginning of the block is enough to free it. This can be accomplished through the use of accounting information, often hidden adjacent to the memory block itself.

Implement malloc() and free() to work as wrappers around getmem() and freemem() to provide this API. The malloc() function should pad the request size to include an accounting block before calling getmem(), and stores the accounting information after the allocation. The free() function recovers the accounting information to provide the size to freemem().

Grading

Project credit will be divvied up evenly between getting memory, freeing memory, compaction, and getstk() removal. By now, you should be aware that rigorous testing is the key to success in these projects. Our test cases will include at least:


[back]

[Revised 2023 Mar 29 13:57 DWB]