Am I doing anything wrong? Here is some relevant portion of my code:
__________________________________
use threads;
...
...
...
my $thr1 = threads->new(\&sub1, @det_files);
my $thr2 = threads->new(\&sub1, @det_files1);
$thr1->join;
$thr2->join;
...
...
__________________________________
And here is the output from perl -V
_______________________________
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=linux, osvers=2.4.21-1.1931.2.382.entsmp,
archname=i386-linux-thread-multi
uname='linux str'
config_args='-des -Doptimize=-O2 -g -pipe -march=i386 -mcpu=i686 -Dmyhostnam
e=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat,
Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux -Dvendorprefix
=/usr -Dsiteprefix=/usr -Dotherlibdirs=/usr/lib/perl5/5.8.0 -Duseshrplib -Du
sethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -
Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallus
rbinperl -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef'
useithreads=define usemultiplicity=
useperlio= d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=un uselongdouble=
usemymalloc=, bincompat5005=undef
Compiler:
cc='gcc', ccflags
='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-ali
asing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr
/include/gdbm',
optimize='',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-st
rict-aliasing -I/usr/local/include -I/usr/include/gdbm'
ccversion='', gccversion='3.2.2 20030222 (Red Hat Linux 3.2.2-5)',
gccosandvers=''
gccversion='3.2.2 200302'
intsize=r, longsize=r, ptrsize=5, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long'
k', ivsize=4'
ivtype='l, nvtype='double'
o_nonbl', nvsize=, Off_t='', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='gcc'
l', ldflags =' -L/u'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil
perllibs=
libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, libperl=libper
gnulibc_version='2.3.2'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so', d_dlsymun=undef,
ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/CORE'
cccdlflags='-fPIC'
ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5', lddlflags='s
Unicode/Normalize XS/A'
Characteristics of this binary (from libperl):
Compile-time options: DEBUGGING MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT
Locally applied patches:
MAINT18379
Built under linux
Compiled at Aug 13 2003 11:47:58
@INC:
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
__________________________________
Thanks in advance!
-AG-
> I am trying to use the capabilities of a multi(4) processor system to split
> a task by using threads. But when I run the program I see only one cpu being
> used although I have spawned 2 threads.
I am not an expert for Perl's threading capabilities. However, the POSIX
thread library it uses (where available) isn't quite yet ready for SMP
and wont distribute the threads over the processors (AFAIK).
For a real multi-processor system you should be using something else.
One standard for parallel programming is MPI. See for instance
<http://www-unix.mcs.anl.gov/mpi/>
for an introduction on MPI and MPICH which is a very reasonable free
implementation of it.
Naturally, MPI (Message Passing Interface) is very different from
threads. No data is shared between processors and must be passed around
explicitely. As it is used in the field of scientific computing, the
libraries you find for it are for C and FORTRAN. With Parallel::MPI and
Parallel::MPI::Simple there are two Perl modules available.
[...]
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
Alas, the only machine I have with 5.8 is a single CPU, but on
it each thread shows up a different process (with top), so I'm assuming
they would run simultaneously if I were to have multiple CPUs.
But there is one difference I notice in our versions that may be important:
> useithreads=define usemultiplicity=
> useperlio= d_sfio=undef uselargefiles=define usesocks=undef
your usemultiplicity seems to be unset (but strangly isn't listed as undef,
like must others are), while mine is :
usemultiplicity=define
I don't know that this is the problem, but it is what I would look into
first.
Well, actually, I'd probably not use threading at all, but rather fork.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
Alas, the only machine I have with 5.8 is a single CPU, but on
it each thread shows up a different process (with top), so I'm assuming
they would run simultaneously if I were to have multiple CPUs.
But there is one difference I notice in our versions that may be important:
> useithreads=define usemultiplicity=
> useperlio= d_sfio=undef uselargefiles=define usesocks=undef
your usemultiplicity seems to be unset (but strangly isn't listed as undef,
like most others are), while mine is :
I haven't looked at the standards in this regards, but on at least
one variety of "real" SMP (SGI Challenge XL), what happens is that
each of the threads may run on a different CPU but the time is
added into a single accounting structure -- resulting in oddities
like having a single process that is taking 700% of a CPU.
--
Warning: potentially contains traces of nuts.
Thanks!
"Walter Roberson" <robe...@ibd.nrc-cnrc.gc.ca> wrote in message
news:c49p87$8e3$1...@canopus.cc.umanitoba.ca...