Re: Re: A question about _thread_ of Linux

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Cheng...

> --------------------results----------------------------------------
> main posix tid:3086476976
> main pid: 14700
> main tid: 14700
> In the thread 0:posix tid 3086474144
> In the thread 0:pid 14700
> In the thread 0:tid 14701
> In the thread 1:posix tid 3075984288
> In the thread 1:pid 14700
> In the thread 1:tid 14702

I got similar result. "pid"s are same for all threads, tids are unique 
for each threads, and so is the posix tid. 

BTW, try this:
$ LD_ASSUME_KERNEL=2.4.9 ./testku

you will get something like below:

main posix tid: 16384
main pid: 4657
main tid: 4657
In the thread 0:posix tid 16386
In the thread 0:pid 4659
In the thread 0:tid 4659
In the thread 1:posix tid 32771
In the thread 1:pid 4660
In the thread 1:tid 4660

Fun isn't it? :) suddenly POSIX tid now use smaller number. Also, since 
we disable NPTL here, "getpid" returns unique numbers too :)

Furthermore, if you trace the code using strace, you will find out that 
pthread_self doesn't generate any syscall. Thus, my not-so-smart 
conclusion is, pthread is maintaining its own thread id table, and this 
id is probably correlated with each current->pid. To be sure, try to 
dig inside pthread source code.

regards,

Mulyadi

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux