Hi,
Is there documentation somewhere that would explain what needs to be done to make (eg) Math::GMP threadsafe ?
My (implicit) assertion that Math::GMP is not threadsafe is based on the fact that the following script segfaults when run on a threaded build of perl (and where Math::GMP itself has been built against a libgmp that is reentrant and threadsafe):
use threads;
use warnings;
use Math::GMP;
$th1 = threads->new(\&start_thread1, '123' x 11);
$ret1 = $th1->join();
if(ref($ret1) eq 'Math::GMP') {
print "\$ret1 => ", ref($ret1), " ", Math::GMP::get_str_gmp($ret1, 1
+0), "\n";
}
sub start_thread1 {
my $mbi = Math::GMP->new($_[0]);
return $mbi;
}
I'm seeking information that doesn't pre-suppose that the reader is threads-savvy. Just a simple "how to" (if such exists) would be best .... anything more detailed would quite likely be lost on me :-)
I have another question: Is Math::BigInt threadsafe ? On the basis that the following script outputs the expected value, I'm thinking the answer could well be "yes":
use threads;
use warnings;
#use Math::Pari;
use Math::BigInt;
$th1 = threads->new(\&start_thread1, '123' x 11);
$ret1 = $th1->join();
print $ret1, "\n";
sub start_thread1 {
my $mbi = Math::BigInt->new($_[0]);
return $mbi;
}
__END__
Outputs:
123123123123123123123123123123123
But then - if I so much as load Math::Pari then that script, too, segfaults. Does that indicate that Math::BigInt is *not* threadsafe ? Or does it merely indicate that one ought not to load Math::Pari in a script that invloves threading ?
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.