Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to compile the simplest snippet I can using pp with Strawberry Perl on Windows tp submit threads.
The code runs just fine with just loose perl
Running "pp -x ThreadTest.pl -o ThreadTest.o" runs just fine and creates an exe file.
Running the resulting executable fails every time.
Parent reports child. Child reports in and runs, then fails as last child code exits.
If run with multiple threads, all submit, all check in, all seem to exit, then it errors out.
How can we compile code with threads for windows? Is it a perl problem or a Windows problem?
#Hash of Child PIDs our %ChildPids; #my $MaxThreadsAtOneTime = 5; #my $MaxThreadsAtOneTime = 2; my $MaxThreadsAtOneTime = 1; my $ThreadsToRun = 50; #### MAIN # Submit first group of children print("Submitting first batch of children\n"); my $ThreadNum = 0; while (($ThreadNum < $MaxThreadsAtOneTime) && ($ThreadNum < $ThreadsToRun)) { $ThreadNum++; my $ChildPid; if ($ChildPid = fork) { # parent code # Collect pid print("Parent found Child $ThreadNum with pid $ChildPid\n"); $ChildPids{$ChildPid} = $ThreadNum; } elsif (defined $ChildPid) { # child code print(" Child pid $$ checking in as thread $ThreadNum\n"); my $SleepTime = int(rand(30)); print(" Child pid $$ sleeping for $SleepTime seconds\n"); sleep $SleepTime; print(" Child pid $$ exiting\n"); exit(); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Compiling with pp on Strawberry Perl on Windows with threads fails
by NetWallah (Canon) on Jul 07, 2016 at 21:36 UTC | |
by rminsko (Initiate) on Jul 08, 2016 at 17:17 UTC | |
by NetWallah (Canon) on Jul 08, 2016 at 19:03 UTC | |
by naudefj (Initiate) on Jul 10, 2016 at 20:03 UTC | |
by Anonymous Monk on Jul 10, 2016 at 20:39 UTC |