Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Mar 1998 15:23:32 -0500
From:      Christopher Masto <chris@netmonger.net>
To:        perl5-porters@perl.com, nvp@mediaone.net
Cc:        hackers@FreeBSD.ORG
Subject:   Perl, Threads, FreeBSD, High Weirdness
Message-ID:  <19980309152332.35831@netmonger.net>

next in thread | raw e-mail | index | archive | help
Here are the latest results of my investigations into _62's thread
situation:

First, I'm 95% sure that the test suite is broken:

  sub islocked
  {
   use attrs 'locked';
   my $val = shift;
   my $ret;
   if (@_)
    {
     $ret = new Thread \&islocked,shift;
     sleep 2;
    }
   print $val;
  }

  $t = islocked("ok 6\n","ok 7\n");
  join $t;

That 'join $t;' should be '$t->join;'.  It's being interpreted as a
Perl join, not a thread join.

Further, in order for that to be of any use, islocked() should
return $ret at the end.

There's also another 'join $t' mistake in the next (8/9) test.

Now the more sad part with FreeBSD:

  # test that sleep lets other thread run
  $t = new Thread \&islocked,"ok 8\n";
  sleep 6;
  print "ok 9";
  join $t;

Pretending the last line is fixed, this test still fails on FreeBSD
(2.2.5-stable as of yesterday).  I don't know why, but I do know that
threads are simply not working.  They do not run concurrently.

This test program:

  use Thread;

  $t = Thread->new(sub { print "AAA\n" while 1; });
  while (1) {
    print "---\n";
    sleep 1;
  }

Produces this output:

---
---
---
---
---
(ad infinitum)

If the main program ever performs a $t->join or exits, the AAA thread
takes over and actually can't be stopped with a ^C or ^\ (but kill -9
from another session works).

Either I'm completely misunderstanding the semantics of the Thread stuff
(the documentation _is_ a bit skimpy right now (I will try to help remedy
that if I ever get this working)), or something's truly screwy.

I'm encouraged by the fact that it compiles, links, and runs.. this is
much more than used to happen.  But it don't go right.
-- 
	       Christopher Masto <chris@netmonger.net>
	Director of Operations, NetMonger Communications, Inc.
    +1-516-221-6664  http://www.netmonger.net/  info@netmonger.net

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980309152332.35831>