Hi, I was wondering if anyone could confirm that declaring many scalar shared variables will crash ActiveStatePerl on WindowsXP, or a comparable newer Windows version. I am using the latest ActiveState5.8.7.813 on WindowsME and the following script, will run with $max_chan_prog <=3 , but will crash with a "panic cond_init(0)" for large values like 60. The script runs fine on linux.

So I'm wondering if this just because of poor memory management in WindowsME, or if all Windows OS levels do this. Code in the readmore below.

#!/usr/bin/perl use warnings; use strict; use threads; use threads::shared; #############shared hashes for xml processor################# my @chs = (1..99); # setting this to 2 works on windowsME # but will bog down over 3, and crash # at values like 60 my $max_prog_chan = 60; my %days; foreach my $channel(@chs){ foreach my $count(0..$max_prog_chan){ #print "$channel $count\n"; share $days{$channel}{$count}{'channel'}; share $days{$channel}{$count}{'channel_info'}; share $days{$channel}{$count}{'episode_num'}; share $days{$channel}{$count}{'start'}; share $days{$channel}{$count}{'stop'}; share $days{$channel}{$count}{'makedate'}; share $days{$channel}{$count}{'description'}; share $days{$channel}{$count}{'title'}; share $days{$channel}{$count}{'writer'}; share $days{$channel}{$count}{'director'}; share $days{$channel}{$count}{'actors'}; share $days{$channel}{$count}{'rating'}; share $days{$channel}{$count}{'length'}; share $days{$channel}{$count}{'category'}; share $days{$channel}{$count}{'star_rating'}; } } my %shash; share $shash{'go'}; share $shash{'progress'}; share $shash{'channels'}; share $shash{'day'}; share $shash{'data'}; share $shash{'pid'}; share $shash{'die'}; $shash{'go'} = 0; $shash{'progress'} = 0; $shash{'channels'} = @chs; $shash{'day'} = ''; $shash{'data'} = ''; $shash{'pid'} = ''; $shash{'die'} = 0; $shash{'thread'} = threads->new( \&xmlwork); ################################################### ##########shared hash for downloader thread########### my %dhash; share $dhash{'go'}; share $dhash{'progress'}; share $dhash{'output'}; share $dhash{'die'}; $dhash{'go'} = 0; $dhash{'progress'} = 0; $dhash{'output'} = ''; $dhash{'die'} = 0; $dhash{'thread'} = threads->new( \&downthread); ######################################################## #start threads running $shash{'go'} = 1; $dhash{'go'} = 1; #wait <>; ################################################################### ################### xml Thread code below ######################### ################################################################### sub xmlwork{ $|++; while(1){ if($shash{'die'} == 1){ goto END }; if ( $shash{'go'} == 1 ){ print "starting xml\n"; for(1..100){ print "xml->$_\n"; sleep 1; } print "\n\ndone xml\n"; if($shash{'go'} == 0){last} if($shash{'die'} == 1){ goto END }; #after above processing is done $shash{'go'} = 0; #turn off self before returning }else { sleep 1 } } #------------------------------------------------------------ END: #end of thread code block } ##################################################################### ##################################################################### ##################################################################### ################# downloader thread below ########################### ##################################################################### ##################################################################### sub downthread{ $|++; while(1){ if($dhash{'die'} == 1){ goto END }; if ( $dhash{'go'} == 1 ){ for(1..100){ print "\tdload->$_\n"; sleep 1; if($dhash{'go'} == 0){last} if($dhash{'die'} == 1){ goto END }; } #after above processing is done $dhash{'progress'} = 0; $dhash{'go'} = 0; #turn off self before returning }else { sleep 1 } } END: #end of downloader thread block } #------------------------------------------------------------ ###################################################################### +## __END__

In reply to threaded shared hashes-- linux vs. win32 by zentara

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.