COSC 125 Operating Systems

Spring 2006

Homework Assignment #7

Dynamic Memory Allocation

Due: Thursday, Apr 13, 5:00PM CST
Submit: E-mail tar-ball (see below) of operating system code to professor, with a subject header "COSC 125 HW#7, Team ???".
Written answers to the five analysis questions below are due at the start of class on the due date. Work may be completed in pairs. Each team should submit only once. Be certain to put both team member names on work submitted. It would be courteous to carbon-copy your partner when e-mailing the final submission.
Preparation

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

Untar the new project files on top of this directory:
   tar xvzf ~brylow/cosc125/xinu-hw7.tar.gz

You should now see the new project files in with your old files. Be certain to make clean before compiling for the first time.
Sleep

Modify system/sleep.c, system/wakeup.c, system/insertd.c, and system/clkintr.c to add the sleep() system call to the operating system. Test this thoroughly before moving on to the next section.

Create a main program that demonstrates sleep() is working, called main-sleep.c, and make sure that it works when copied over main.c.
Getmem and Freemem

The files include/mem.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.

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. The new system/kill.c has already been modified to call freemem() to deallocate the process stack.
Testing

  • Create testcases to verify that your getmem() and freemem() functions operate correctly over a variety of request sizes.
  • Create testcases to allocate and free as much memory as possible. How can you tell whether or not you have a memory leak?
  • Create a testcase to verify that your freemem() compaction works.

  • Back