Perl isn't thread safe. You'll need to do one of the
following:
- Use some sort of mutex to prevent simultaneous
access to the Perl interpreter, making a "critical section"
that only one thread can use at a time. I believe someone
has already built this so you might be able to find it.
- Create (a pool of) separate Perl interpreters for
each thread that needs to call a Perl subroutines. This
won't work for you if the subroutines need to act on shared
data. Note that you can use the same Perl interpreter in
different threads so long as the Perl interpreter is
not built with threading support and only one thread
uses that interpreter at a time.
- Try embedding a Perl interpreter built with one
of the several experimental methods for supporting multiple
thread per interpreter and access the interpreter as
required by that method. This will cause the interpreter
to use mutexes to make critical sections around smaller
chunks of code. But none of these work 100% reliably so
you'll have to deal with that.
There might be some other methods, but the above should
give you a feel for what is required.
Please contact me at poorna@india.hp.com
Sorry, you'll have to check back here.
-
tye
(but my friends call me "Tye")
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|