Arthur, Here's a quick look at the problems I'm having with ithreads on bleadperl. I hope this provides a useful starting point.
Summary: - unlock doesn't work (threads::shared::unlock_enabled is undefined) - if the 'parent' thread exits before one of its 'children', Perl seems very unhappy (aside: do we talk about parents and children in the world of ithreads?) I've included: - my test script, lock.t (no, it's not written like a proper Perl test script, but I'm sure that can be arranged). Supplying the cmd line arg 20 means that the parent thread will exit before the 2nd child on my system; supplying 30 means the 2nd child exits first. - output from this script - perlbug5.7.2 -d output for my system Andy ================================================================== #!/opt/bleadperl/bin/perl5.7.2 -w # lock.t # A test of perl threads $sleep_length = $ARGV[0]; # 20 causes a problem, 30 is OK use Config; use threads; use threads::shared; if($Config{'useithreads'} && $threads::threads) { print "\nWe've got threads...\n"; } else { print "\nWe've NOT got threads.\n"; exit; } our $lockv = 0; share($lockv); sub thrd { my($me) = shift; sleep $me; print "This is thread ${me}. lockv=$lockv\n"; sleep 5; lock($lockv); $lockv++; print "Thread $me has the lock! lockv=$lockv\n"; sleep 5; print "Thread $me has just slept for 5 sec since it got it's lock.\n"; $lockv++; sleep 5; print "Thread $me has slept another 5 sec since it got it's lock. " . "lockv=$lockv\n"; # this causes a problem unlock($lockv); print "Thread $me exiting.\n"; } print "\nMain thread. lockv=$lockv\n"; my $t1 = threads->create('thrd', '1'); # The 'detach's seem to make no difference #$t1->detach(); my $t2 = threads->create('thrd', '2'); #$t2->detach(); print "Main thread just started other threads. lockv=$lockv\n"; # if this is 20, then seg fault, # if it is 30, then no seg fault sleep $sleep_length; print "Main thread last's line. lockv=$lockv\n\n"; ====================================================================== $ lock.t 20 v-string in use/require non-portable at /opt/bleadperl/lib/5.7.2/i686-linux-thread-multi/threads.pm line 3. Unquoted string "threads" may clash with future reserved word at ./lock.t line 44. Unquoted string "threads" may clash with future reserved word at ./lock.t line 47. We've got threads... Main thread. lockv=0 Died:Undefined subroutine &threads::shared::unlock_enabled called at ./lock.t line 38. Main thread just started other threads. lockv=0 This is thread 1. lockv=0 This is thread 2. lockv=0 Thread 1 has the lock! lockv=1 Thread 1 has just slept for 5 sec since it got it's lock. Thread 1 has slept another 5 sec since it got it's lock. lockv=2 Unbalanced scopes: 3 more ENTERs than LEAVEs Unbalanced saves: 8 more saves than restores Unbalanced context: 2 more PUSHes than POPs Segmentation fault $ lock.t 30 v-string in use/require non-portable at /opt/bleadperl/lib/5.7.2/i686-linux-thread-multi/threads.pm line 3. Unquoted string "threads" may clash with future reserved word at ./lock.t line 44. Unquoted string "threads" may clash with future reserved word at ./lock.t line 47. We've got threads... Main thread. lockv=0 Died:Undefined subroutine &threads::shared::unlock_enabled called at ./lock.t line 38. Main thread just started other threads. lockv=0 This is thread 1. lockv=0 This is thread 2. lockv=0 Thread 1 has the lock! lockv=1 Thread 1 has just slept for 5 sec since it got it's lock. Thread 1 has slept another 5 sec since it got it's lock. lockv=2 Died:Undefined subroutine &threads::shared::unlock_enabled called at ./lock.t line 38. Thread 2 has the lock! lockv=3 Thread 2 has just slept for 5 sec since it got it's lock. Thread 2 has slept another 5 sec since it got it's lock. lockv=4 Main thread last's line. lockv=4 ====================================================================== Site configuration information for perl v5.7.2: Configured by andy at Mon Feb 25 20:38:45 GMT 2002. Summary of my perl5 (revision 5.0 version 7 subversion 2 patch 14868) configuration: Platform: osname=linux, osvers=2.4.2-2, archname=i686-linux-thread-multi uname='linux localhost.localdomain 2.4.2-2 #1 sun apr 8 20:41:30 edt 2001 i686 unknown ' config_args='' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm', optimize='-O2', cppflags='-D_REENTRANT -fno-strict-aliasing -I/usr/include/gdbm' ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.1 2.96-81)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -lndbm -lgdbm -ldl -lm -lpthread -lc -lcrypt -lutil perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil libc=/lib/libc-2.2.2.so, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib' Locally applied patches: DEVEL14868 --- @INC for perl v5.7.2: /opt/bleadperl/lib/5.7.2/i686-linux-thread-multi /opt/bleadperl/lib/5.7.2 /opt/bleadperl/lib/site_perl/5.7.2/i686-linux-thread-multi /opt/bleadperl/lib/site_perl/5.7.2 /opt/bleadperl/lib/site_perl . --- Environment for perl v5.7.2: HOME=/home/andy LANG=en_GB LANGUAGE (unset) LD_LIBRARY_PATH=/usr/lib LOGDIR (unset) PATH=/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/home/andy/bin:./ PERL_BADLANG (unset) SHELL=/bin/bash ===== Andy Bussey Email [EMAIL PROTECTED] Mobile 07814 740887 __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com