TM Research Journal

Friday, March 17, 2006

DSTM C Coding Obstable

I have encountered an obstacle in the coding of DSTM in C. I thought taht maybe writing it down will help me see the big picture and hopefully get around it.

In DSTM, when a transaction begins, each thread creates an object of type Transaction. This transaction object keeps track of the current status of the transaction and whether it's Active, Committed or Aborted.

Now all objects point to the last transaction which has accessed them. When an object is opened for writing, if it is pointing to a committed or aborted transaction then access is granted.

The problem is, in Java, whenever a transaction is created the programmer doesn't worry about deallocating the memory its using since the garbage collector is responsible for doing that when no more objects or threads are pointing to that transaction. While in C, we should deallocate the transaction manually.

The question is, when do we deallocate it? If we deallocate it when the transaction commits, then all the objects that are committed and poiting to this transaction will point to some unknown place in memory. We cannot deallocate it when the object stops pointing to it since we don't know how many objects are pointing to it.

The first idea I have in mind to to create a write list, but after thinking about it more I thought that a counter for every transaction might be better.

Let's have an object counter for every transaction. Whenever an object points to it we increment the counter. Whenever an object stops pointing to it we decrement it. When the counter reaches zero we deallocate the transaction. A new trasnaction is always allocated by every thread at the start of a transaction.

I just realized that this is actually a method of garbage collection known as reference counting. In this case though, this will be more efficient than a generally garbage collected environment since it is limited to a certain portion.

0 Comments:

Post a Comment

<< Home