On Sat, Jan 03, 2004 at 08:05:13PM +0100, Elizabeth Mattijsen wrote:
> At 18:20 +0000 1/3/04, Nigel Sandever wrote:
> > Sharing data between the threads/interpreters is implemented by
> > tieing the two copies of the variables to be shared and each time
> > a STORE is performed in one thread, the same STORE has too be
> > performed on the copy of that var held on every other threads
> > dataspace.
> 
> Hmmm.... is that true?  My impression was (and that's the way I've 
> implemented it in Thread::Tie) is that each STORE actually stores the 
> value in a hidden background thread, and each FETCH obtains the 
> current value from the background thread.  I don't think each STORE 
> is actually cascading through all of the threads.  Not until they try 
> to fetch the shared value, anyway.

Sharing consists of the real SV living in a shared interpreter, with each
individual thread having a lightweight proxy SV that causes the
appropriate real SV to be accessed/updated by a mixture or magic and/or
tied-ish access. A particular access by one thread does not involve any of
the other threads or their proxies.

> > With ithreads, there can be no shared references, so no shared
> > objects and no shared compound data structures
> 
> Actually, you can bless a reference to a shared variable, but you 
> can't share a blessed object (the sharing will let you lose the 
> content of the object).  I think shared compound data structures 
> _are_ possible, but very tricky to get right (because the CLONE sub 
> is called as a package method, rather than as an object method: see 
> Thread::Bless for an attempt at getting around this).

Nested shared structures work just fine, and there's no need to mess with
CLONE for plain data.

> >And the reaction from those wh have tried to make use of ithreads
> >under p5 are all too aware that replicating them for Parrot would
> >be ..... [phrase deleted as too emotionally charged:)]

It's the implementation of ithreads in p5 that sucks, not the concept
itself. The use of COW makes new thread creation cheap, and the use of
lock PMCs interposed on the real PMCs makes shareing easy.

Dave.

-- 
O Unicef Clearasil!
Gibberish and Drivel!
                      - "Bored of the Rings"

Reply via email to