On 5/8/06, cheng long <kevinclcn@xxxxxxxxx> wrote:
Hi, Arun > I "guess" the 'pid' field of task_struct would be returned, as > pthread_self() by definition returns the calling thread's ID which in the > kernel should be the thread's pid.Somebody please CMIIW.
Yes, There is a syscall sys_gettid() which returns pid field of task struct. When a thread is created the threads gets a unique pid and its parent's (creator's) tgid. pid serves as a thread id and tgid serves as a "pid of a process in POSIX language".
Since "printf("thread id: %u\n", pthread_id())" will generate a very larger number than "printf("process id: %u\n", getpid() )", so I don't think pthread_self() will return the pid field of it's task_struct.
Why do you think so? pid is allocated by pid types. ie. pid is allocated differently for process (i mean those created with CLONE_THREAD) and threads. so they are so different. regards Manish Regmi -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/