zentara has asked for the wisdom of the Perl Monks concerning the following question:
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__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: threaded shared hashes-- linux vs. win32
by pg (Canon) on Sep 17, 2005 at 15:41 UTC | |
|
Re: threaded shared hashes-- linux vs. win32
by zentara (Cardinal) on Sep 17, 2005 at 17:28 UTC | |
|
Re: threaded shared hashes-- linux vs. win32
by puploki (Hermit) on Sep 17, 2005 at 14:44 UTC | |
by pg (Canon) on Sep 17, 2005 at 15:44 UTC |