Difference between revisions of "Assignment: Heap Memory"

From Embedded Xinu
Jump to navigation Jump to search
(New page: Category:Student Built Xinu = Delta Queues = This assignment is a Xinu assignment allowing the student to grow a more firm understanding of how an operating system works. This assi...)
 
 
Line 1: Line 1:
 
[[Category:Student Built Xinu]]
 
[[Category:Student Built Xinu]]
= Delta Queues =
+
= Heap Memory =
This assignment is a [[Xinu]] assignment allowing the student to grow a more firm understanding of how an operating system works. This assignment is part of the [[Student Built Xinu]] track for professors that are [[Teaching With Xinu]]. Your entire working directory containing your Xinu operating system will be submission for this assignment.
+
This assignment is a [[Xinu]] assignment allowing the student to more firmly understanding of how an operating system works. This assignment is part of the [[Student Built Xinu]] track for professors that are [[Teaching With Xinu]]. The entire working directory containing your Xinu operating system will be submission for this assignment.
 
== Preparation ==
 
== Preparation ==
 
First, make a fresh copy of your work thus far.
 
First, make a fresh copy of your work thus far.
Line 8: Line 8:
 
   tar xvzf <tar-ball location>
 
   tar xvzf <tar-ball location>
 
You should now see the new project files in with your old files. Be certain to make clean before compiling for the first time.
 
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 ==
+
== Getmem and Freemem ==
Modify <code>system/sleep.c</code>, <code>system/wakeup.c</code>, <code>system/insertd.c</code>, and <code>system/clockintr.c</code> to add the <code>sleep()</code> system call to the operating system. A process that calls <code>sleep(n)</code> should enter the <code>PRSLEEP</code> state for n clock ticks. A clock "tick" is one millisecond in our current system. It corresponds to the raising of the timer interrupt request when interrupts are not disabled. When the clock interrupt handler detects that a process has slept for long enough, the <code>wakeup</code> function should move the process back to the ready list.
+
The files <code>include/memory.h</code> and <code>system/initialize.c</code> define and initialize a free list of available memory blocks on the heap. Implement <code>system/getmem.c</code> and <code>system/freemem.c</code> 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.)
  
The appropriate data structure for maintaining a list of sleeping processes is a ''delta queue'', as described in lecture. Add a delta queue to the system by increasing the <code>QENT</code> constant in <code>include/queue.h</code>, declaring a queue called "sleepq" in <code>include/clock.h</code>, and and defining and initializing <code>sleepq</code> in <code>system/clockinit.c</code>. Make sure to test your delta queue in isolation before testing the <code>sleep()</code> function.
+
Delete the file <code>system/getstk.c</code> and replace the lone call to this function in <code>system/create.c</code> with a proper call to <code>getmem()</code> instead. Modify <code>system/kill.c</code> to call <code>freemem()</code> to deallocate a process stack when a process dies.
 
== Grading ==
 
== Grading ==
Project credit will be weighted evenly between delta queue maintenance, sleeping, and waking processes. By now, you should be aware that rigorous testing is the key to success in these projects. Our test cases will include at least:
+
Project credit will be divvied up evenly between getting memory, freeing memory, and compaction. By now, you should be aware that rigorous testing is the key to success in these projects. Our test cases will include at least:
* Checking your delta queue insert function with a variety of parameters
+
* Verifying that your <code>getmem()</code> and <code>freemem()</code> functions operate correctly over a variety of request sizes
* Checking your sleeping and waking functions independently and in concert.
+
* 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?)
 +
* Verifying that your <code>freemem()</code> compaction works.

Latest revision as of 07:32, 12 December 2008

Heap Memory

This assignment is a Xinu assignment allowing the student to more firmly understanding of how an operating system works. This assignment is part of the Student Built Xinu track for professors that are Teaching With Xinu. The entire working directory containing your Xinu operating system will be submission for this assignment.

Preparation

First, make a fresh copy of your work thus far.

  cp -R <old Xinu directory> <new Xinu directory>

Untar the new project files on top of this new directory:

  tar xvzf <tar-ball location>

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

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.)

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, and compaction. 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?)
  • Verifying that your freemem() compaction works.