On Sun, 4 Jan 2004 15:47:35 -0500, [EMAIL PROTECTED] (Dan Sugalski) wrote:

> *) INTERPRETER - those bits of the Parrot_Interp structure that are 
> absolutely required to be thread-specific. This includes the current 
> register sets and stack pointers, as well as security context 
> information. Basically if a continuation captures it, it's the 
> interpreter.
> 
> *) INTERPRETER ENVIRONMENT - Those bits of the Parrot_Interp 
> structure that aren't required to be thread-specific (though I'm not 
> sure there are any) *PLUS* anything pointed to that doesn't have to 
> be thread-specific.
> 
> The environment includes the global namespaces, pads, stack chunks, 
> memory allocation regions, arenas, and whatnots. Just because the 
> pointer to the current pad is thread-specific doesn't mean the pad 
> *itself* has to be. It can be shared.
> 

> *) SHARED THREAD - A thread that's part of a group of threads sharing 
> a common interpreter environment.

Ignoring the implementation of the synchronisation required, the basic
premise of my long post was that each SHARED THREAD, should have it's
own INTERPRETER (a VM in my terms). and that these should share a 
common INTERPRETER ENVIRONMENT.

Simplistically, 5005threads shared an INTERPRETER ENVIRONMENT 
and a single INTERPRETER. Synchronising threaded access to the shared
INTERPRETER (rather than it's environment) was the biggest headache.
(I *think*).

With ithreads, each SHARED THREAD has it's own INTERPRETER *and*
INTERPRETER ENVIRONMENT. This removes the contention for and the
need to synchronise access to the INTERPRETER, but requires the 
duplication of shared elements of the INTERPRETER ENVIRONMENT and
the copy_on_read, with the inherent costs of the duplication at start-up, 
and slow, indirect access to shared entities across the duplicated 
INTERPRETER ENVIRONMENTS.

My proposal was that each SHARED THREAD, 
should have a separate copy of the INTERPRETER, 
but share a copy of the INTERPRETER ENVIRONMENT.

Everything else, were my attempts at solving the requirements of 
synchronisation that this would require, whilst minimising the cost
of that synchronisation, by avoiding the need for a mutex on every
shared entity, and the costs of attempting to aquire a mutex except
when two SHARED THREADS attempted concurrent access to a
shared entity. 

I think that by having SHARED THREAD == INTERPRETER, sharing
a common INTERPRETER ENVIRONMENT, you can avoid (some) of 
the problems associated with 5005threads but retain the direct 
access of shared entities. 

This imposes it's own set of requirements and costs, but (I believe)
that the ideas that underly the mechanisms I offered as solutions
are sound. The specific implementation is a platform specific detail
that could be pushed down to a lower level.

> ...those bits of the Parrot_Interp 
> structure that aren't required to be thread-specific (though I'm not 
> sure there are any) 

This is were I have a different (and quite possibly incorrect) view.
My mental picture of the INTERPRETER ENVIRONMENT includes
both the impementation of all the classes in the process *plus* all
the memory of every instance of those classes. 

I think your statement above implies that these would not be a part
of the INTERPRETER ENVIRONMENT per se, but would be allocated 
from global heap and only referenced from the bytecode that would live
in the INTERPRETER ENVIRONMENT? 

I realise that this is possible, and maybe even desirable, but the cost
of the GC walking a global heap, especially in the situationof a single 
process that contains to entirely separate instances of the 
INTERPRETER ENVIRONMENT, would be (I *think*) rather high.

I realise that this is a fairly rare occurance on mist platforms,
but in the win32 situation of emulated forks, each pseudo-process
must have an entirely separate INTERPRETER ENVIRONMENT,
potentially with each having multiple SHARED THREADS. 

If the memory for all entities in all pseudo-process is allocated from 
a (real) process-global heap, then the multiple GC's required by the 
multiple pseudo-process are going to be walking the same heap.
Possibly concurrently.  I realise that this problem (if it is such)
does not occur on platforms that have real forks available, but it
would be useful if the high level design would allow for the use of
separate (virtual) heaps tied to the INTERPRETER ENVIRONMENTs
which win32 has the ability to do.


> 
>                                          Dan
>

Nigel.



Reply via email to