develooper Front page | perl.ithreads | Postings from November 2008

Re: XS: MY_CXT vs PL_modglobal?

Thread Previous | Thread Next
From:
Shmuel Fomberg
Date:
November 1, 2008 15:27
Subject:
Re: XS: MY_CXT vs PL_modglobal?
Message ID:
490CD7AE.50208@012.net.il
Dave Mitchell wrote:
>> A question about threads from the XS-embedding-module perspective:
>> What is the difference between MY_CXT and PL_modglobal?
> 
> PL_modglobal is a general perl-interpreter hash.

So, if a interpreter creates new threads, every thread get its own copy 
of PL_modglobal?

>> I have implemented C running Perl module that embed a C XS function, and  
>> want to pass a pointer to that function from the C code that runs Perl.
>> The Perl side span multiple threads, and each call that C function.
> 
> The usual way of doing this is to store the pointer in an SV using using
> the PTR2UV and INT2PTR macros. This may remove your need to use MY_CXT.

To hide the pointer inside a global (our) variable? And let the Perl 
name space be my storage. nice.

>> So, what is the difference between MY_CXT and PL_modglobal? not in the  
>> global scope that one have while the other is local, but from threads  
>> safety question.
> 
> I'd need more details on how how your are creating and using threads and
> interpreters to be able to answer that.

There is a C program (STAF) that runs a multiple Perl interpreters, each 
spanning multiple threads, and each thread is calling a certain XS 
function.
The C program needs to supply context to the XS function, so for every 
Perl that is creates it malloc a certain structure, and store the 
pointer inside PL_modglobal.

Shmuel.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About