develooper Front page | perl.perl5.porters | Postings from February 2003

Re: thread safe

Thread Previous | Thread Next
A . Bergman
February 2, 2003 15:24
Re: thread safe
Message ID:

On söndag, feb 2, 2003, at 21:22 Europe/Stockholm, Brandon Willis wrote:

> Arthur,
> I don't see how creating many PerlInterpreter*'s will help as calls 
> like
> get_sv and the rest do not take in a PerlInterpreter* and thus would
> have no way of knowing which PerlInterpreter I meant them to act on.
> I must be missing a piece of information.  Do the internal calls 
> somehow
> "know" that they are to act on one PerlInterpreter versus another? If
> not how do I tell them "Hey you get_sv work on PerlInterpreter A."?
> If I cannot give internal calls context then really I think my only
> option is to learn how to spawn ithreads directly from C.
> Thanks,
> --Brandon

Hi, what happens is that all your get_sv gets translated to

where aTHX is a argumentTHreadconteXt object which is the perl 
interpreter, it lives in
a thread local key, and when creating a new perl interpreter that is set

Good way is to read the source code for threads.xs to see how it does 
it, basicly the
two macrost  PERL_SET_CONTEXT(PerlInterpreter*) and PERL_GET_CONTEXT.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About