At 6:38 PM -0800 12/21/03, Jeff Clites wrote:
On Dec 21, 2003, at 5:44 PM, Dan Sugalski wrote:

At 5:31 PM -0800 12/21/03, Jeff Clites wrote:
It sounds like an assumption here is that separate threads get separate interpreter instances. I would have thought that a typical multithreaded program would have one interpreter instance and multiple threads (sharing that instance). I would think of separate interpreter instances as the analog of separate independent processes (at the Unix level), and that threads would be something more lightweight than that. There would be _some_ structure which is per-thread, but not logically the whole interpreter.

Been there, done that, got the scars to prove it. Doesn't work well in a system with guarantees of internal consistency and core data elements that are too large for atomic access by the processor. (And, while you can lock things, it gets really, really, *really* slow...)

1) It seems like you've made a leap here. I don't see how the need to guarantee the internal consistency of things such as strings directly implies per-thread allocation pools or file-descriptor tables. Having non-shared HLL-accessible data doesn't imply non-shared internal data structures.

We've a copying garbage collector. That pretty much requires per-thread memory pools and higher-level mediated access to allocated collectable memory. Otherwise things get... nasty.


2) Separate issue really, but: How can a language such as Java, which doesn't have inter-thread data-access restrictions, be implemented on top of Parrot?

Easily, albeit with a bit of a speed hit for threaded code. (Java has immutable strings which cuts out a lot of the need for synchronization, since you don't need any for immutable data) If all access is through PMCs, and it needs to be, you use the threaded version of the PMC vtables, which automatically get and release the PMC lock. (That's what the synchronization entry on the PMC is for, to hold the mutex or whatever it is for this)
--
Dan


--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to