develooper Front page | perl.perl5.porters | Postings from April 2000

Multithreading Perl

Thread Next
From:
Geoffrey Wossum
Date:
April 6, 2000 13:25
Subject:
Multithreading Perl
Message ID:
200004062025.PAA10905@omega.uta.edu
Hi,

Sorry if this is the wrong list for this question, but it seemed like the
list that would most likely be able to answer my question.  Please direct
me to the correct list if I am wrong.

I would like to apply an external threading mechanism, such as pthreads or
Solaris threads, to multiple Perl interpreters.  Something that will look
roughly like the following pseudocode:

----
void *perl_func(void *arg)
{
    PerlInterpreter *perl;

    setup_perl_interpreter in perl;
    run some perl code in perl;
    pull some data out of interpreter and pass back to caller;
}

...

    pthread_t perl_threads[PERL_THREAD_NUM];

    foreach i = PERL_THREAD_NUM {
        pthread_create(perl_threads + i, &perl_func, parm);
    }

    wait for threads to complete;
    pull data out of threads;
...
----

According to all the documentation I've found, the Perl interpreter has
been thread-safe since 5.005.  Is this true?  I see the interpreter
looking at a lot of global data...

I've tried compiling perl with a variety of options, includeing
MULTIPLICITY and THREADS and various other things.  The program either
core dumps, or it seems that only one Perl interpreter is really there.

So the questions are:  

Can I do this with Perl (5.005 or 5.6)?  
If so, what's the secret?  How do I need to compile Perl?  Do I need to do
something special with my external threading mechanism?
If I can't currently do this with Perl, is this capability on the horizon?

TIA,

---
Geoffrey Wossum
gwossum@acm.org
Project AKO - http://rover1.uta.edu/~ako
Internet Imperialists - http://inetimperial.sourceforge.net
  



   
    

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