Background
Consider an object oriented programming environment where all objects inherit
the following methods from the universal object superclass:
- next -- identity of the next object in the heap
- prev -- identity of the previous object in the heap
- marked -- returns a boolean value
- mark(v) -- future calls to marked will return v
- done -- causes the object to deallocate itself
- touch -- a "virtual method" that must be defined for every object
In addition, the environment defines first and last as global functions
that return pointers to the first and last objects currently allocated on
the heap, and the heap manager raises the heap-empty exception when an
allocation cannot be performed.
Part A:
Write pseudocode for the touch method of an object, assuming that the combined
touch methods of all objects, taken together, are supposed to perform the
marking phase of a mark-sweep garbage collector.
Part B:
Write pseudocode for a sweep function that could be called
on receipt of a notice of a heap-empty exception.
Part C:
What major problems remain unsolved by the definitions of this hypothetical
programming environment and by your answers to part A and B that would
cause difficulty in the use of mark-sweep garbage collection in this
environment.