[30063] in Perl-Users-Digest
Perl-Users Digest, Issue: 1306 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 25 14:14:34 2008
Date: Mon, 25 Feb 2008 11:14:23 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 25 Feb 2008 Volume: 11 Number: 1306
Today's topics:
Processing workload distribution <r.ted.byers@rogers.com>
Re: Processing workload distribution <ben@morrow.me.uk>
Re: Processing workload distribution <smallpond@juno.com>
Re: Processing workload distribution xhoster@gmail.com
Re: Processing workload distribution <r.ted.byers@rogers.com>
Re: Processing workload distribution <r.ted.byers@rogers.com>
Re: Processing workload distribution <r.ted.byers@rogers.com>
Re: Processing workload distribution <ben@morrow.me.uk>
Re: Processing workload distribution <joost@zeekat.nl>
Re: Processing workload distribution xhoster@gmail.com
Re: Processing workload distribution <r.ted.byers@rogers.com>
Re: Processing workload distribution <r.ted.byers@rogers.com>
Re: Processing workload distribution <ben@morrow.me.uk>
Re: Processing workload distribution <ben@morrow.me.uk>
Re: Processing workload distribution <joost@zeekat.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 25 Feb 2008 08:23:19 -0800 (PST)
From: Ted <r.ted.byers@rogers.com>
Subject: Processing workload distribution
Message-Id: <2e37250c-5fe0-44aa-a1df-51ab18b82d68@28g2000hsw.googlegroups.com>
The machine is a single processor/quad core server running the latest
Windows Server.
The Perl we're using is the 64 bit build of 5.8.8 from Activestate.
I created a script that uses threads to launch a series of standalone
SQL scripts (I use system to invoke mysql to run my SQL scripts). I
had thought that system was spawning child processes, but it seems
that the script that launches them waits on each child before
launching the next. It is looking like the threads launches all
without wating for the next, which is closer to what I want.
However, regardless of what I have tried so far, all the hard work is
being done by one core, with the other three mostly sitting idle.
What can I do to distribute the workload evenly over all the cores in
the machine? The whole purpose of this machine was to serve as a
compute server for my colleagues and I, and in fact only two of us
have a need to access it, and this is so we can run heavy duty DB
analysis programs on it. The code works adequately, but it seems a
shame to have invested in a quad core processor based machine only to
have all the work done on only one core. I don't care if I have to
launch threads or child processes, as long as I can distribute the
work more evenly. Is what I am after possible?
Thanks
Ted
BTW: are there any 64 bit modules on CPAN? The repository for the 64
bit build that Activestate has provided seems to be empty.
------------------------------
Date: Mon, 25 Feb 2008 17:14:55 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Processing workload distribution
Message-Id: <fl9b95-ap4.ln1@osiris.mauzo.dyndns.org>
Quoth Ted <r.ted.byers@rogers.com>:
> The machine is a single processor/quad core server running the latest
> Windows Server.
>
> The Perl we're using is the 64 bit build of 5.8.8 from Activestate.
>
> I created a script that uses threads to launch a series of standalone
> SQL scripts (I use system to invoke mysql to run my SQL scripts).
In general it is easier to talk to the database directly using DBI than
to launch external mysql processes. In this case, however, you may find
it easier to make things run in parallel with an external command.
> I had thought that system was spawning child processes, but it seems
> that the script that launches them waits on each child before
> launching the next.
Yes, this is how system works. As a special case, on Windows only,
calling
my $pid = system 1, "mysql ...";
(with a literal 1 as the first argument) will spawn a new process and
*not* wait for it. You can use the returned pid as an argument to wait
or waitpid. Alternatively, for more control, you can use Win32::Process
or IPC::Run.
> It is looking like the threads launches all without wating for the
> next, which is closer to what I want.
You would have to post your code for us to see what is happening here. I
think probably each thread is launching one child and waiting for it,
but since you have several threads you have several children.
> However, regardless of what I have tried so far, all the hard work is
> being done by one core, with the other three mostly sitting idle.
Are you *certain* you end up with more than one mysql process running at
a time? You should be able to check easily with Task Manager. If you
don't, then you need to fix that (or switch to using DBI to talk to the
database and Perl threads for parallelism). If you do, yet they are all
running on the same core, then something odd is happening: you will need
to show us a (minimal) script that runs two processes at the same time
that still end up on the same core.
> BTW: are there any 64 bit modules on CPAN? The repository for the 64
> bit build that Activestate has provided seems to be empty.
Modules on CPAN are (generally-speaking) architecture-neutral, given
that CPAN only holds C and Perl source. If ActiveState don't provide
64-bit ppms, then you can install pure-Perl modules directly from CPAN,
but XS modules will require a copy of the compiler used to build your
perl, probably a 64-bit version of MSVC. You may be able to get gcc
working (the 32-bit version of AS Perl has support for building modules
with gcc), but I don't know how well the 64-bit version is supported.
Ben
------------------------------
Date: Mon, 25 Feb 2008 09:23:34 -0800 (PST)
From: smallpond <smallpond@juno.com>
Subject: Re: Processing workload distribution
Message-Id: <85f54a90-658c-47e7-b43b-e2632b8c1be2@s13g2000prd.googlegroups.com>
On Feb 25, 11:23 am, Ted <r.ted.by...@rogers.com> wrote:
> The machine is a single processor/quad core server running the latest
> Windows Server.
>
> The Perl we're using is the 64 bit build of 5.8.8 from Activestate.
>
> I created a script that uses threads to launch a series of standalone
> SQL scripts (I use system to invoke mysql to run my SQL scripts). I
> had thought that system was spawning child processes, but it seems
> that the script that launches them waits on each child before
> launching the next. It is looking like the threads launches all
> without wating for the next, which is closer to what I want.
>
> However, regardless of what I have tried so far, all the hard work is
> being done by one core, with the other three mostly sitting idle.
>
> What can I do to distribute the workload evenly over all the cores in
> the machine? The whole purpose of this machine was to serve as a
> compute server for my colleagues and I, and in fact only two of us
> have a need to access it, and this is so we can run heavy duty DB
> analysis programs on it. The code works adequately, but it seems a
> shame to have invested in a quad core processor based machine only to
> have all the work done on only one core. I don't care if I have to
> launch threads or child processes, as long as I can distribute the
> work more evenly. Is what I am after possible?
>
> Thanks
>
> Ted
>
> BTW: are there any 64 bit modules on CPAN? The repository for the 64
> bit build that Activestate has provided seems to be empty.
See perlthrtut and check your perl build with: perl -V
Look for a line like:
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
I believe that the last part indicates whether perl tries to use
multiple
CPUs.
------------------------------
Date: 25 Feb 2008 17:26:15 GMT
From: xhoster@gmail.com
Subject: Re: Processing workload distribution
Message-Id: <20080225122617.176$WL@newsreader.com>
Ted <r.ted.byers@rogers.com> wrote:
> The machine is a single processor/quad core server running the latest
> Windows Server.
>
> The Perl we're using is the 64 bit build of 5.8.8 from Activestate.
>
> I created a script that uses threads to launch a series of standalone
> SQL scripts (I use system to invoke mysql to run my SQL scripts). I
> had thought that system was spawning child processes, but it seems
> that the script that launches them waits on each child before
> launching the next.
That is what Perl's "system" does. It spawns a child process, and then
waits for it.
> It is looking like the threads launches all
> without wating for the next, which is closer to what I want.
>
> However, regardless of what I have tried so far, all the hard work is
> being done by one core, with the other three mostly sitting idle.
Generally (not always, but generally) the hard work of an SQL query
is done by the server, not the client. If your MySQL database server fails
to use all the cores in doing it's job, that is not a Perl problem, that is
a MySQL problem.
If you don't think this describes your situation, then launch the four
standalone SQL scripts separately from Windows. If you launch them this
way, are all cores used? If not, then you don't have a Perl problem.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Mon, 25 Feb 2008 10:08:24 -0800 (PST)
From: Ted <r.ted.byers@rogers.com>
Subject: Re: Processing workload distribution
Message-Id: <4ce5829b-e08c-40c3-8906-1176660ea47e@q33g2000hsh.googlegroups.com>
On Feb 25, 12:23=A0pm, smallpond <smallp...@juno.com> wrote:
> On Feb 25, 11:23 am, Ted <r.ted.by...@rogers.com> wrote:
>
>
>
>
>
> > The machine is a single processor/quad core server running the latest
> > Windows Server.
>
> > The Perl we're using is the 64 bit build of 5.8.8 from Activestate.
>
> > I created a script that uses threads to launch a series of standalone
> > SQL scripts (I use system to invoke mysql to run my SQL scripts). =A0I
> > had thought that system was spawning child processes, but it seems
> > that the script that launches them waits on each child before
> > launching the next. =A0It is looking like the threads launches all
> > without wating for the next, which is closer to what I want.
>
> > However, regardless of what I have tried so far, all the hard work is
> > being done by one core, with the other three mostly sitting idle.
>
> > What can I do to distribute the workload evenly over all the cores in
> > the machine? =A0The whole purpose of this machine was to serve as a
> > compute server for my colleagues and I, and in fact only two of us
> > have a need to access it, and this is so we can run heavy duty DB
> > analysis programs on it. =A0The code works adequately, but it seems a
> > shame to have invested in a quad core processor based machine only to
> > have all the work done on only one core. =A0I don't care if I have to
> > launch threads or child processes, as long as I can distribute the
> > work more evenly. =A0Is what I am after possible?
>
> > Thanks
>
> > Ted
>
> > BTW: are there any 64 bit modules on CPAN? =A0The repository for the 64
> > bit build that Activestate has provided seems to be empty.
>
> See perlthrtut and check your perl build with: perl -V
> Look for a line like:
>
> usethreads=3Ddefine use5005threads=3Dundef useithreads=3Ddefine
> usemultiplicity=3Ddefine
>
> I believe that the last part indicates whether perl tries to use
> multiple
> CPUs.- Hide quoted text -
>
> - Show quoted text -
Yes, both on my development machine (only a dual core) and on the quad
core server, I see this: use of both threads and multiplicity are
there. Near the top of the output from perl -V, I see:
usethreads=3Ddefine use5005threads=3Dundef useithreads=3Ddefine
usemultiplicity=3Ddefine
And lower down I see,
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
PERL_IMPLICIT_SYS PERL_MALLOC_WRAP
PL_OP_SLAB_ALLOC USE_ITHREADS USE_LARGE_FILES
USE_PERLIO USE_SITECUSTOMIZE
When I launch four mysql commands separately, I see four instances of
it in task manager, and the work load is distributed over all four
cores. So the problem must be in my code (See my reply to myself).
Thanks
Ted
------------------------------
Date: Mon, 25 Feb 2008 10:09:15 -0800 (PST)
From: Ted <r.ted.byers@rogers.com>
Subject: Re: Processing workload distribution
Message-Id: <b5af06dd-a1a2-4f9d-b491-b4284e24a6a4@z17g2000hsg.googlegroups.com>
On Feb 25, 12:26=A0pm, xhos...@gmail.com wrote:
> Ted <r.ted.by...@rogers.com> wrote:
> > The machine is a single processor/quad core server running the latest
> > Windows Server.
>
> > The Perl we're using is the 64 bit build of 5.8.8 from Activestate.
>
> > I created a script that uses threads to launch a series of standalone
> > SQL scripts (I use system to invoke mysql to run my SQL scripts). =A0I
> > had thought that system was spawning child processes, but it seems
> > that the script that launches them waits on each child before
> > launching the next.
>
> That is what Perl's "system" does. =A0It spawns a child process, and then
> waits for it.
>
> > It is looking like the threads launches all
> > without wating for the next, which is closer to what I want.
>
> > However, regardless of what I have tried so far, all the hard work is
> > being done by one core, with the other three mostly sitting idle.
>
> Generally (not always, but generally) the hard work of an SQL query
> is done by the server, not the client. =A0If your MySQL database server fa=
ils
> to use all the cores in doing it's job, that is not a Perl problem, that i=
s
> a MySQL problem.
>
> If you don't think this describes your situation, then launch the four
> standalone SQL scripts separately from Windows. =A0If you launch them this=
> way, are all cores used? =A0If not, then you don't have a Perl problem.
>
> Xho
>
> --
> --------------------http://NewsReader.Com/--------------------
> The costs of publication of this article were defrayed in part by the
> payment of page charges. This article must therefore be hereby marked
> advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate=
> this fact.
yes, so I have a perl problem (or probably more accurately my use of
perl is the problem).
Thanks
Ted
------------------------------
Date: Mon, 25 Feb 2008 10:15:37 -0800 (PST)
From: Ted <r.ted.byers@rogers.com>
Subject: Re: Processing workload distribution
Message-Id: <5e69ebec-ea7b-4fec-acd3-3fab3e6782cb@e10g2000prf.googlegroups.com>
Here is my code:
use threads;
my $thr0 = threads->create(\&dbspawn,'e5pf16.sql','e5pf16.log');
$thr0->join;
my $thr1 = threads->create(\&dbspawn,'gpf45.sql','gpf45.log');
$thr1->join;
my $thr2 = threads->create(\&dbspawn,'gpf46.sql','gpf46.log');
$thr2->join;
my $thr3 = threads->create(\&dbspawn,'gpf47.sql','gpf47.log');
$thr3->join;
my $thr4 = threads->create(\&dbspawn,'gpf48.sql','gpf48.log');
$thr4->join;
my $thr5 = threads->create(\&dbspawn,'gpf49.sql','gpf49.log');
$thr5->join;
my $thr6 = threads->create(\&dbspawn,'gpf50.sql','gpf50.log');
$thr6->join;
sub dbspawn {
local ($script,$log) = @_;
system("mysql -t -u rejbyers --password=jesakos yohan < $script >
$log") == 0 or die "$script failed!";
}
Is the problem the way I use "system"?
When this script is running, I only ever see one instance of mysql
running in task manager.
Is there a Win64::process, or will Win32::process work on a 64 bit
version of windows using the 64 bit build of perl?
Thanks
Ted
------------------------------
Date: Mon, 25 Feb 2008 18:07:35 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Processing workload distribution
Message-Id: <7ocb95-qn5.ln1@osiris.mauzo.dyndns.org>
Quoth smallpond <smallpond@juno.com>:
>
> See perlthrtut and check your perl build with: perl -V
> Look for a line like:
>
> usethreads=define use5005threads=undef useithreads=define
> usemultiplicity=define
>
> I believe that the last part indicates whether perl tries to use
> multiple CPUs.
Please don't make things up and post them without verifying.
Multiplicity indicates whether it is possible to have several perl
interpreters in the same process: this is a requirement for ithreads (so
any perl with useithreads=define will also have usemultiplicity=define)
but is also used without ithreads for e.g. mod_perl. It has *nothing* to
do with use of multiple CPUs: this is determined by your OS's thread
scheduling policy.
Ben
------------------------------
Date: Mon, 25 Feb 2008 19:25:30 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Processing workload distribution
Message-Id: <87skzguc4l.fsf@zeekat.nl>
Ted <r.ted.byers@rogers.com> writes:
> Here is my code:
>
> use threads;
>
> my $thr0 = threads->create(\&dbspawn,'e5pf16.sql','e5pf16.log');
> $thr0->join;
you should join() all threads /after/ creating all of them. a join()
blocks untill the thread is done. In other words, move the ->join()
calls to the end of script.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: 25 Feb 2008 18:30:52 GMT
From: xhoster@gmail.com
Subject: Re: Processing workload distribution
Message-Id: <20080225133054.403$c5@newsreader.com>
Ted <r.ted.byers@rogers.com> wrote:
> Here is my code:
>
> use threads;
>
> my $thr0 = threads->create(\&dbspawn,'e5pf16.sql','e5pf16.log');
> $thr0->join;
Join means you wait for $thr0 to finish. Obviously this is going
to lead to serialization. The simple answer is to move all the joins
from where they are and put them after all of the creates have been done.
The *right* answer is probably to put the thread objects into an array,
then after that loop over that array doing joins, rather than using a bunch
of different variables to hold the objects.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Mon, 25 Feb 2008 10:34:08 -0800 (PST)
From: Ted <r.ted.byers@rogers.com>
Subject: Re: Processing workload distribution
Message-Id: <13e11ce5-c807-4bff-a597-52f1ba6b7f85@u10g2000prn.googlegroups.com>
On Feb 25, 1:25=A0pm, Joost Diepenmaat <jo...@zeekat.nl> wrote:
> Ted <r.ted.by...@rogers.com> writes:
> > Here is my code:
>
> > use threads;
>
> > my $thr0 =3D threads->create(\&dbspawn,'e5pf16.sql','e5pf16.log');
> > $thr0->join;
>
> you should join() all threads /after/ creating all of them. a join()
> blocks untill the thread is done. In other words, move the ->join()
> calls to the end of script.
>
> --
> Joost Diepenmaat | blog:http://joost.zeekat.nl/| work:http://zeekat.nl/
Ah, OK.
While it is not likely in this case, since the scripts normally take
several hours to run, what happens if you create half a dozen threads,
and one of them finishes before you get to join it?
Also, I recall reading somewhere that some system calls block
everything in the process until the system call returns. Is that
true? If so, which are involved, and what would be the workaround?
Thanks
Ted
------------------------------
Date: Mon, 25 Feb 2008 10:53:03 -0800 (PST)
From: Ted <r.ted.byers@rogers.com>
Subject: Re: Processing workload distribution
Message-Id: <43db91c7-7e79-40bd-9dc3-45adc6152db9@i7g2000prf.googlegroups.com>
On Feb 25, 1:30=A0pm, xhos...@gmail.com wrote:
> Ted <r.ted.by...@rogers.com> wrote:
> > Here is my code:
>
> > use threads;
>
> > my $thr0 =3D threads->create(\&dbspawn,'e5pf16.sql','e5pf16.log');
> > $thr0->join;
>
> Join means you wait for $thr0 to finish. =A0Obviously this is going
> to lead to serialization. =A0The simple answer is to move all the joins
> from where they are and put them after all of the creates have been done.
> The *right* answer is probably to put the thread objects into an array,
> then after that loop over that array doing joins, rather than using a bunc=
h
> of different variables to hold the objects.
>
> Xho
>
> --
> --------------------http://NewsReader.Com/--------------------
> The costs of publication of this article were defrayed in part by the
> payment of page charges. This article must therefore be hereby marked
> advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate=
> this fact.
Yup that was it.
This script was just a test to make sure I got it all right. I was
going to worry about putting it into arrays after I got it right.
that means one array for the script name, a second for the log name,
and a third for the thread objects.
I saw Joost's post before I saw yours, and set up a trivial test,
involving selecting everything from each of three tables, and
displaying them in the command line window. Yes, that window looks
like a mess, but it is getting all the data and it looks like the work
load is being distributed evenly, and I see an instance of mysql in
Task Manager for each thread. So now just a little rewriting to make
good use of arrays, and to simplify the code.
Thanks all.
Ted
------------------------------
Date: Mon, 25 Feb 2008 18:51:33 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Processing workload distribution
Message-Id: <lafb95-336.ln1@osiris.mauzo.dyndns.org>
Quoth Ted <r.ted.byers@rogers.com>:
> Here is my code:
>
> use threads;
>
> my $thr0 = threads->create(\&dbspawn,'e5pf16.sql','e5pf16.log');
> $thr0->join;
> my $thr1 = threads->create(\&dbspawn,'gpf45.sql','gpf45.log');
> $thr1->join;
> my $thr2 = threads->create(\&dbspawn,'gpf46.sql','gpf46.log');
> $thr2->join;
> my $thr3 = threads->create(\&dbspawn,'gpf47.sql','gpf47.log');
> $thr3->join;
> my $thr4 = threads->create(\&dbspawn,'gpf48.sql','gpf48.log');
> $thr4->join;
> my $thr5 = threads->create(\&dbspawn,'gpf49.sql','gpf49.log');
> $thr5->join;
> my $thr6 = threads->create(\&dbspawn,'gpf50.sql','gpf50.log');
> $thr6->join;
As others have said, join waits for the thread, so you need to do it
last. Also, this is *not* an efficient way to create many threads. I
would probably write something like
$_->join for map {
threads->create(\&dbspawn, "$_.sql", "$_.log");
} qw/e5pf16 gpf45 gpf46 gpf48 gpf49 gpf50/;
or probably drop the sub altogether and use async:
$_->join for map {
async {
system "mysql -t -u rejbyers <$_.sql >$_.log"
and warn "$script failed";
# there's little point in dieing when the thread's about to
# exit anyway...
}
} qw/.../;
but you may find something a little less compressed easier to
understand:
my @jobs = qw/e5pf16 gpf45 .../;
my @threads = map {
async {
system "...";
}
} @jobs;
$_->join for @threads;
Of course, given that you only use the threads to launch processes, you
would be better off just launching processes:
my @procs = map { system 1, "..." } @jobs;
waitpid $_ for @procs;
> Is there a Win64::process, or will Win32::process work on a 64 bit
> version of windows using the 64 bit build of perl?
I don't know. That is, there isn't a Win64::Process, and I don't know
whether Win32::Process works on Win64. That depends on whether the
underlying Win32 system calls still work the same way: I suspect they
do. There are no Win64 results from CPAN Testers (surprise), which is
usually the first place to look. In any case, since there aren't any
Win64 ppms, you'd need to compile libwin32 from source. Do you have an
appropriate compiler?
Ben
------------------------------
Date: Mon, 25 Feb 2008 19:02:00 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Processing workload distribution
Message-Id: <8ufb95-336.ln1@osiris.mauzo.dyndns.org>
Quoth Ted <r.ted.byers@rogers.com>:
> On Feb 25, 1:25 pm, Joost Diepenmaat <jo...@zeekat.nl> wrote:
> > Ted <r.ted.by...@rogers.com> writes:
> > > Here is my code:
> >
> > > use threads;
> >
> > > my $thr0 = threads->create(\&dbspawn,'e5pf16.sql','e5pf16.log');
> > > $thr0->join;
> >
> > you should join() all threads /after/ creating all of them. a join()
> > blocks untill the thread is done. In other words, move the ->join()
> > calls to the end of script.
>
> Ah, OK.
>
> While it is not likely in this case, since the scripts normally take
> several hours to run, what happens if you create half a dozen threads,
> and one of them finishes before you get to join it?
It sits there, consuming a small amount of memory in your Perl process,
until you do. This is exactly the same as a 'zombie' process under Unix.
If you don't want this to happen, and don't care about the return value
of the thread, you can ->detach it, which will cause it to clean itself
up as soon as it finishes. However, if your main thread exits, any
detached threads will be silently destroyed, so if this is a problem you
will need to join them.
> Also, I recall reading somewhere that some system calls block
> everything in the process until the system call returns. Is that
> true? If so, which are involved, and what would be the workaround?
This depends on your underlying threads implementation, and is rarely
true any more (most systems use some sort of 'real' kernel threads,
which don't behave like this).
Ben
------------------------------
Date: Mon, 25 Feb 2008 20:04:14 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Processing workload distribution
Message-Id: <87oda4uac1.fsf@zeekat.nl>
Ted <r.ted.byers@rogers.com> writes:
> While it is not likely in this case, since the scripts normally take
> several hours to run, what happens if you create half a dozen threads,
> and one of them finishes before you get to join it?
if the thread has already finished, the join() should just return
immediately (after possibly doing some cleanup). Note that you should
always either join() or detach() each thread.
> Also, I recall reading somewhere that some system calls block
> everything in the process until the system call returns.
Besides thread-specific calls, like the ones used by threads::shared's
synchronization methods, I don't know of anything like that. From perl's
point of view, you should probably regard threads as completely seperate
processes that have some nifty additional IPC mechanisms.
This also implies that unless you need those sharing mechanisms, you're
not gaining anything by using threads instead of fork() - and you're
quite likely to be losing efficiency and gaining some possible issues) -
at least on OSs that support fork natively. Though I gather that on
Windows systems, the situation is different.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 1306
***************************************