Hi - I got interested in 5.8 threads too...

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
> zentara
> Sent: Sunday, February 02, 2003 4:53 AM
> To: [EMAIL PROTECTED]
> Subject: threads and pids
> 
> 
> Hi,
> I just got interested in 5.8 threads. I have a simple question
> about the first basic example in perlthrtut.
> 
> My basic question is how to track the pids, and why does the
> following program create 4 pids instead of 3? I would expect
> 3, one for the parent, and one for each of 2 threads. 
> 
> So run the following program and watch it with "top c". 4 pids
> are generated. What is that extra pid for?
> 
> Also does anyone know how to get the individual threads pids?
> I can get the tid, but can't seem to find the pid, except the parents.
> 
> #!/usr/bin/perl
> use threads;
> 
> print "I'm the parent pid-> $$\n";
> $thr = threads->new(\&sub1);
> $thr1 = threads->new(\&sub1);
> sleep 25;
> 
> sub sub1{
> $myobject = threads->self;
> $mytid= $myobject->tid;
> print "In the thread $myobject $mytid \n";
> sleep 20;
> }
> 

Correct me (someone) if I'm wrong, but a thread is a
THREAD not a PROCESS. So a thread has a thread id (tid)
but (depending on the implementation) not necessarly)
a process id (pid). I think you should stick to tids
when working with threads.

Also, this:

 $myobject = threads->self;
 $mytid= $myobject->tid;

can be shortcut to:

 $mytid = threads->tid;

Aloha => Beau;




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to