develooper Front page | perl.perl5.porters | Postings from January 2012

Re: Is PL_check thread-safe?

Thread Previous | Thread Next
From:
Father Chrysostomos
Date:
January 1, 2012 13:17
Subject:
Re: Is PL_check thread-safe?
Message ID:
C13E0F73-4A00-4345-AAAD-0483E560A7CD@cpan.org

On Dec 29, 2011, at 3:21 AM, Leon Timmermans wrote:

> On Sun, Dec 11, 2011 at 10:18 PM, Father Chrysostomos <sprout@cpan.org> wrote:
>> Please correct me if I’m wrong:  PL_check is global.    That means the dozens of modules that do this:
>> 
>>    old_ck_thingy = PL_check[OP_THINGY];
>>    PL_check[OP_THINGY] = my_ck_thingy;
>> 
>> are not thread-safe, right?  What happens if another thread assigns to PL_check[OP_THINGY] in between those two assignments?  Is there a mutex that XS modules can use to avoid the race condition?
>> 
>> If not, does Perl need to provide such a mutex?
> 
> Is there any reason why it has to be global?

Does BOOT run each time an XS module is required or just when the object file is loaded?

If the former, then we could make PL_check an interpreter variable.

One thing I can never get straight is C’s array declaration syntax.  Presumably PL_check would be an array in the interpreter struct with a fixed length, but I never know what I’m getting when declaring arrays in C.  (I find pointers much easier to understand, even though books on C say that pointers are harder to understand than arrays. :-)


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