,
Marquette University logo      

 

 

NOW DUE FRIDAY, April 5, 5:00 P.M.

Submit: Turn in your source code using the turnin command on the lab machines. Submit your entire xinu-hw8 directory for this assignment.

Work should be completed in pairs. Be certain to include both names in the comment block at the top of all altered files. It would be courteous to confirm with your partner when submitting the assignment.

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

Remember: these two commands should be run in the same path. Don't change directories before running this tar command, or else you'll have two xinu-hw8 directories in different places.

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

Multicore Memory Safety

What happens when multiple cores attempt to allocate or free the same memory block at the same time? This race condition can be avoided if the proper precautions are taken. To make your implementation multicore-safe, refer to the TODO statements in getmem.c, freemem.c, malloc.c, and free.c .

Getmem and Freemem

The files include/memory.h and system/initialize.c define and initialize a free list 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 on 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 in the memory block itself.

Implement system/malloc.c and system/free.c to work as wrappers around getmem() and freemem() to provide this API. The malloc function pads the request size to include an accounting block and stores the accounting information after the allocation. The free() function recovers the accounting information to provide the size to freemem().

Down With Getstk()

Delete the file system/getstk.c and replace the lone call to this function in system/create.c with a proper call to getmem() instead. Modify system/kill.c to call freemem() to deallocate a process stack when a process dies.

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:

  • Verifying that your getmem() and freemem() functions operate correctly over a variety of request sizes,
  • Checking your memory free list under a wide variety of conditions; if you are not writing a helper function to print out your free list, you are probably not serious about understanding what your system is doing,
  • Allocating and freeing as much memory as possible, (How can you tell whether you have a memory leak?), and
  • Verifying that your freemem() compaction works.

 

 
  Marquette University. Be The Difference. Marquette | Corliss |