CS 536 Homework 7: Garbage Collection

Due: November 8, both hardcopy in class and electronically via turnin (asgmt name hwk7)


You have two options for this assignment:

  1. Implement both mark & sweep, and stop & copy.
  2. Implement a generational garbage collector
Both assignments carry the same weight, so choose based on which option you'll find more interesting/challenging/educational/etc. Details about each option are after the following section on the GC API in DrScheme.


Info Common to Both Options

Write your garbage collectors in the GC Collector Scheme language level. This language defines an interface to a program's stack and heap that you will use to implement garbage collection.

Your garbage collectors must implement the following functions:

To help you write these functions, the GC Collector Scheme language defines an interface for the heap and the roots (the roots is the set of pointers into the heap from the stack):

Testing your Garbage Collectors

You may write programs that exercise your garbage collectors using the GC Mutator Scheme language. This language is a subset of Scheme that uses a garbage collector that you specify. The first line of a test program must be:

(allocator-setup "collector.ss" heap-size heap-offset)

"collector.ss" must be the name of your collector's file. heap-size is the size of the heap your collector will use. heap-offset is the base address on the heap where allocation should start (usually 0).

The remainder of the program is in a subset of Scheme with numbers, symbols, lists, etc. The primitives of the language map directly to the procedures you define in your garbage collector.

Sample Code

To get you started, here are a sample mutator and a trivial collector that signals an error when the heap fills up. (this collector does signal an error with this mutator, if you don't increase the size of the heap.)

Notes

Store bookkeeping data for your collector on the heap provided by GC Collector Scheme. You may store 2-3 atomic values, such as addresses into the heap (for the semispaces) as variables in your garbage collector. We will assume they represent machine registers. However, all compound data structures must be on the heap.

Some final words of advice:


Option 1 Details


Option 2 Details


What to submit

Submit a separate file for each collector you implement, as well as two examples of test/mutator files that you used to test your collectors. Include a comment in each mutator file describing what it was designed to test. You only need to turn in printouts of the collectors.


Back to the Assignments page