Hi browserUK,

is there some problem in the below code :-

use strict; use threads; use threads::shared; use Thread::Queue; my @clientList = qw( client1 client2 client3 client4 client5 client6 ); my @queryList = qw( query1 query2 query3 query4 query5 query6 ); my $maxnoofQueryThreads = 15; my $maxnoofCompThreads = 30; my $globalQ = new Thread::Queue; my $queryBossID = threads->new(\&queryBoss,$globalQ); my $compBossID = threads->new(\&compBoss,$globalQ,); $queryBossID->join; $compBossID->join; sub queryBoss { my $q = new Thread::Queue; my $globalQ = shift; my @queryworkers = map {threads->new( \&queryworker, $ +q,$globalQ);} 1 .. $maxnoofQueryThreads; $q->enqueue(@queryList); $q->enqueue( ( undef ) x $maxnoofQueryThreads ); $_->join for @queryworkers; } sub compBoss { my $globalQ = shift; my @compworkers = map {threads->new( \&compworker, $globalQ);} 1 .. +$maxnoofCompThreads; #$q->enqueue(@queryList); $globalQ->enqueue( ( undef ) x $maxnoofCompThreads ); $_->join for @compworkers; } sub compworker { my $globalQ = shift; my $tid = threads->self->tid; while(my $workItem = $globalQ->dequeue) { print " the file is $workItem \n"; #start comparison on the file and dump result in a new file and de +l the file } } sub queryworker { my( $Q ) = shift; my $globalQ = shift; my $tid = threads->self->tid; while( my $workItem = $Q->dequeue ) { for( my $i = 0; $i < @clientList; $i++) { #lock $mtxStdOut; print " workitem from thread $tid -->$workItem\n" +; ## Perform query ## worked on one client for query signal compBoss to start +doing comp ## so enqueue the file location on dum +p my $fileLoc = "$workItem"."$clientList[$i]"; $globalQ->enqueue($fileLoc); } } }

In reply to Re^9: Problem in Inter Process Communication by libvenus
in thread Problem in Inter Process 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.