perl threads



Hi,
Background:
I have task of calculating dependencies of project(s) of a scenario.
Dependency calculation is done using an external command. Since this
dependency calculation time depends on how big is the project is, it
is difficult to guess how much dependency calculation of a scenario(a
set of projects) takes. To overcome this i am using 'threads' module
to create thread and ask each thread to do the dependency calculation.

I have many scenarios currently and i calculate dependency foreach
scenario. I create one thread for each project in the scenario and
wait for all threads to finish, to take on next scenario. Because i
know 'Perl ithreads are not lightweight!', i am using carefully, in
the sense, I'm not using any shared variables between threads. Each
thread will do dependency calculation, which will produces an output
in a file separately. Later i parse those files to get dependency list
for each project.

Problem:
Sometimes* the script waits forever or the script just hangs. That is
waiting for threads. And cant continue with other scenario.

[code]
#this way i create threads
#foreach scenario() ...{
map {my $th = threads->create(\&worker, $_)} @$proj_arr; #proj_arr has
projects of a scenario
# ...}

# This is how i wait for all threads to finish its job
print "waiting for threads to finish";
map {my $k = $_->join} threads->list;
[/code]

Is there a way i can overcome this? Or my perception about cause for
the problem is right? Because from the log i see, only 'waiting for
threads to finish' at last and script will continue. This is happens
only sometimes. Most of the times the script executes fine.

Atleast i want to be informed about the 'script is not responding or
hanged', because the script is scheduled there will be not be any clue
unless and otherwise, myself has to go and check.

Hope i could explain the problem clearly. I am using 'perl, v5.8.8
built for MSWin32-x86-multi-thread'


Thanks in advance,
katharnakh.
.



Relevant Pages

  • Re: perl threads
    ... thread will do dependency calculation, ... Forking an independent process is better. ... And cant continue with other scenario. ... Threads must reach the end of their code blocks, or return, in order ...
    (comp.lang.perl.misc)
  • Re: on input form showing error message for duplicate entry.
    ... my SITE will not crash. ... you can 'what if' the daylights out of this script. ... this scenario DOES NOT exist in this script. ... | i think, there is no sense to speak more about it, think again about my ...
    (alt.php)
  • Re: Tracking Confidential Files - solution?
    ... use a script that connects remotely via windows ... you don't seem too concerned about that in this scenario. ... > inadvertently left on the workstation. ... > We have several shares that contain confidential files. ...
    (microsoft.public.security)
  • Re: Help required to read and print lines based on the type of first character
    ... Here is a scenario, I need to code. ... A script that ... Reads from a file (may be a local file say test.txt) ... You'll see it menctions a few ways to process a file; the cleanest alternative to do it one line at a time is: ...
    (comp.lang.python)
  • Re: organizing your scripts, with plenty of re-use
    ... path ~/mydir) for testing purposes. ... Here's a scenario. ... Change all your imports to package imports. ... Add the following basic script to your Python directory. ...
    (comp.lang.python)