CTM: Exercise 4-2

Posted by Urban Hafner Wed, 02 Nov 2005 16:12:33 GMT

The problem

Threads and garbage collection. This exercise examines how garbage collection behaves with threads and dataflow variables. Consider the following program:

proc {B _}
   {Wait _}
end

proc {A}
   Collectible={NewDictionary}
in
   {B Collectible}
end

After the call {A} is done, will Collectible become garbage? That is, will the memory occupied by Collectible be recovered? Give an answer by thinking about the semantics. Verify that the Mozart system behaves in this way.

My solution

At first I was a bit confused by what is meant with after the call is done and how _ behaves. But then I understood. Wait waits until its argument becomes determined. But when you use _ as an argument that can never happen because it creates a new unbound variable.

This I why I think Collectible can’t be garbage collected. It can’t be done because the call to A isn’t finished yet, because the call to B isn’t finished.

Tags , , , , , , ,

Comments are disabled