Hi Monks,

Is there a way i can let the the compBoss know the contents in the globalQ. The globalQ is being enqueued by the queryWorkers

The application that i m buldling needs parallel prosscessing and more can be read in posts with the title "best strategy" and "Problem in Inter Process Communication".

Thanks,
use strict; use threads; use threads::shared; use Thread::Queue; my @queryList = qw(/dev/files_xls_tmpl_cfg_nonscripts/sql1.clmod.NEW. +txt /dev/files_xls_tmpl_cfg_nonscripts/sql1.clmod.NEW1 +4-78B6R.txt /dev/files_xls_tmpl_cfg_nonscripts/sql1.clmod.NEW14-78B7N. +txt /dev/files_xls_tmpl_cfg_nonscripts/Interest_on_Cash_PATS_c +mt_dt.clmod.txt /dev/files_xls_tmpl_cfg_nonscripts/Interest_on_Cash_PATS_c +mt_dt.clmod14-78B6R.txt /dev/files_xls_tmpl_cfg_nonscripts/Interest_on_Cash_PATS_c +mt_dt.clmod14-78B7N.txt ); print $ARGV[0],"\n"; my $maxnoofQueryThreads = $ARGV[0]; my $maxnoofCompThreads = 2*$ARGV[0]; my $globalQ : shared = new Thread::Queue; my $q = new Thread::Queue; m +y $defSig = undef; my $queryBossID = threads->new(\&queryBoss,$global +Q,$q); my $compBossID = threads->new(\&compBoss,$globalQ,); $queryBossID->join; $compBossID->join; sub queryBoss { print " query boss triggered\n"; my $globalQ = shift; my $q = shift; my @queryworkers = map {threads->new( \&queryworker, $ +q,$globalQ,$_);} 1 .. $maxnoofQueryThreads; $q->enqueue(@queryList); $q->enqueue( ( undef ) x $maxnoofQueryThreads ); $_->join for @queryworkers; } sub compBoss { print " comp boss triggered\n"; my $globalQ = shift; print " i am comp boss and i can see the following items\n",$g +lobalQ->pending; #while(my $workItem = $globalQ->dequeue) { my @compworkers = map {threads->new( \&compworker, $globalQ,$_ +);} 1 .. $maxnoofCompThreads; #$q->enqueue(@queryList); $globalQ->enqueue( ( undef ) x $maxnoofCompThreads ); $_->join for @compworkers; } sub compworker { print " comp worker triggered\n"; my $globalQ = shift; my $id = shift; my $tid = threads->self->tid; print " i am comp worker and i can see the following items\n", +$globalQ->pending; while(my $workItem = $globalQ->dequeue){ print " id $id the file is $workItem \n"; print " i must compare the following file $workItem \n +"; #start comparison on the file and dump result in a new + file and del the file } } sub queryworker { print " query worker triggered\n"; my( $Q ) = shift; my $globalQ = shift; my $id = shift; my $tid = threads->self->tid; while( my $workItem = $Q->dequeue ){ local $/ = undef; #system("client hqsas501 22415 200 \-f $workItem > + $workItem\.prod"); open(HAN,"client hqsas501 22415 200 \-f $workItem +|") || die "$!"; my $prod = <HAN>; #print "prod file slurped $prod\n"; close HAN; #system("client hqsas501 22710 200 \-f $workItem > + $workItem\.test"); open(HAN,"client hqsas501 22710 200 \-f $workItem +|") || die "$!"; my $test = <HAN>; #print "test file slurped $test\n"; close HAN; my $handleProd = $workItem.'prod'; my $handleTest = $workItem.'test'; unless($prod eq $test){ open(HANPRD,">$handleProd") || die "$!"; open(HANTST,">$handleTest") || die "$!"; print " thread it $tid working on $workItem prod an +d test file differ \n"; print HANPRD $prod; print HANTST $test; print " enqueing workitem $workItem\n"; $globalQ->enqueue($workItem); print "$compBossID compbossid\n"; #$compBossID->kill(ALRM); close HANPRD; close HANTST; } print " i am query worker and i can see the following items +\n",$globalQ->pending; } }

In reply to Thread communication by libvenus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.