On Nov 16, 2005, at 19:27, Erik Paulson wrote:


Hello,

As a class project, we're looking at transactional memory, and one of things
we'd like to try and do is add some basic TM support to Parrot.

Cool.

To start out with, we'd add three new opcodes - one to begin, end, and
abort the current transaction. the BeginTX op would save a continuation, abort would just restore that continuation, and commit would throw away the
old continuation and move on.

I'm fine with the 3 new opcodes, ops/experimental.ops is the place to add these. I don't see yet, how Continuations come into the game, but it could very well be ;-)

Then we'd actually try and add transactional memory :)

Some basic questions: is there a notion of "current time" in Parrot, like a cycle counter or anything? I don't see any instructions I could get one from inside a PASM program, and I didn't see any of the .c files keeping
track of one...

No there is nothing like a timestamp / cycle counter.

When we turn on transactions in any thread, any shared variable that is
written to will need to have a timestamp added to it noting when the last
write occurred. Threads that are in transactions will have to keep
track of all the data they read, and when they goes to commit they will
have to check the last-written timestamp on each of the elements in the
readset.

Hmm. My half-baken implementation model is based on vtables. Vaguely like this:
- a shared PMC has a different vtable than a non-shared one
- a shared PMC has basically 3 fields additionally: owner, read_vtable, write_vtable
- the owner (each writer) has a copy of the data and just writes to it
- non-owners (readers) read the original data

A very terse draft is at http://perlcabal.org/~lt/STM.txt

This seems sort of easy to do with PMCs, since we can just latch on to the
vtable and do our bookkeeping there (but wow, that's a lot of functions
that a PMC might implement). How does it work with the builtin types like
int?

We have to split the vtable somewhen into interfaces. A plain Integer doesn't have to implement e.g. an arrayish push or pop operation.

Like most other TM systems, we're punting on I/O for now. It's also not
realistic, but for now you can only be in one transaction.

Yup

Thanks!

I thank you

-Erik

leo

Reply via email to