On 5/10/06, cheng long <kevinclcn@xxxxxxxxx> wrote:
I think the the process which calls pthread_create() is the thread group leader, because it is first lightweight process in the group. So, it's tgid == it's pid.
very true.:)
As your opinion, there should be a thread whose tgid and pid are equal, i.e., getpid() == pthread_self(). Am I wrong?
Yes. But you cannot use pthread_self() in a unithreaded program. I am not 100% sure about this because POSIX has not defined any error condition for pthread_self() and has not told what will happen if it is called in unithread (i mean without pthread_create()). So, i don't know pthread is giving but u can say for a thread group leader tgid == pid getpid() == gettid() Note: gettid is linux specfic. #include <stdio.h> #include <linux/unistd.h> _syscall0(pid_t, gettid) int main() { printf("pid %x, tid %x\n", getpid(), gettid()); return 0; } regards Manish Regmi -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/