I dont know if this is the problem, but why do you issue a system
sleep....perl has a built it sleep [perldoc -f sleep]. Is perl system thread
safe on Solaris ?? Maybe you launch your threads and they are sleeping and
you dont realize it , just my 2 cents.
Mark
----- Original Message -----
From: "Phil Schaechter" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 02, 2003 6:27 PM
Subject: Threads blocking on solaris
> Hi all,
>
> I have a very interesting problem. I have my main program waiting for
data on
> stdin, while other threads are running - and lauching yet more threads.
>
> Threads block while trying to launch new threads until I hit enter. The
code
> below (which I whipped out quickly to demo the problem) blocks until enter
is
> hit on solaris, but runs fine on linux.
>
> Does anyone have any clues for me?
>
> Perl version I run on solaris: This is perl, v5.8.0 built for
> sun4-solaris-thread-multi
>
> Perl version I run on linux: This is perl, v5.8.0 built for
> i686-linux-thread-multi
>
> The code:
>
> #!/usr/bin/perl
> use threads;
> use threads::shared;
>
> my $key, @cmds, $new_thread;
>
> print "> ";
> while ( chop($key = <STDIN>) )
> {
> @cmds = split(/ /, $key);
>
> if ( $cmds[0] eq "run" )
> {
> $new_thread = new threads \&monitor
> }
>
> print "> ";
> }
>
> sub monitor
> {
> my $self_thread = threads->self();
> my $self_id = $self_thread->tid();
>
> while (1)
> {
> system("sleep 15");
> print "calling load_stream_starter...\n";
> load_stream_starter(5);
> print "Load stream starter finished\n";
> }
> }
>
> sub load_stream_starter
> {
> my $to_start = shift;
> my $i, $new_thread, $new_id;
>
>
> for( $i = 0; $i < $to_start; $i++)
> {
> print "Preparing to launch...";
> $new_thread = new threads \&run_func;
> $new_id = $new_thread->tid();
> print "launched $new_id\n";
> }
> }
>
>
> sub run_func
> {
>
> while (1)
> {
> system("sleep 5");
> print "I'm running\n";
> }
> }
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]