[Zope-Perl] Threads

Gurusamy Sarathy gsar@ActiveState.com
Wed, 21 Jun 2000 15:22:36 -0700


On 21 Jun 2000 00:16:51 +0200, Gisle Aas wrote:
>Gurusamy Sarathy <gsar@activestate.com> writes:
>> If you want to run the same interpreter in multiple threads with the
>> 5.6 thread model, you can.  All you have to do is:
>> 
>>   * ensure that more than one thread is not executing the interpreter
>>     at the same time (use a mutex for exclusion)
>
>Can I avoid that the mutex remain blocked, and thus my (only)
>interpreter, if the perl code executing goes to sleep or invoke some
>other slow system call?

Not out of the box, but you should be able to set up your own
implementation of selected "slow" interfaces in iperlsys.h that
unlock the mutex before making the system call.

The other approach is to use more than one interpreter and not
worry about locking.  But it is not clear that this will be
ideal for you.

>What is TLS?

Thread Local Storage.

>>     The general structure is:
>> 
>>         PerlInterpreter *old_perl = PERL_GET_CONTEXT;
>>         PERL_SET_CONTEXT(new_perl);
>> 	{
>> 	    PerlInterpreter *my_perl = new_perl;
>> 	    ...call_sv()/eval_sv() etc...
>
>And when the perl code activated here calls back into python code that
>calls back into perl code...  No problem or what?

Shouldn't be a problem, assuming the recursive invocation also is doing
the same thing.


Sarathy
gsar@ActiveState.com