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

what's the relationship between tgid, tid and pid ?



Linux 2.5.49
NTPL 0.10

I learned from the kernel source. sys_getpid() returns tgid and 
sys_gettid() returns pid. Moreover, 
/kernel/source/fork.c
copy_process() 
771 if (clone_flags & CLONE_PARENT_SETTID)
772 if (put_user(p->pid, parent_tidptr))  // parent_tidptr is tid in struct
pthread
                                   ....
It seems tid = pid, while tgid is head pthread pid. 

But the following lines let me confused.
/kernel/source/fork.c
copy_process()              
893         p->tgid = p->pid;
894         p->group_leader = p;
every pthread_create()->sys_clone()->do_fork()->copy_process()
p->tgid will be overwritten every time?

any comments? thanks. 

  Boris
=========================
To know what I don't know
To learn what I don't know
To contribute what I know
=========================





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