thread id and process id in 2.6 kernel

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

thread id and process id in 2.6 kernel

Guang Lei Li
Hi,

  In the 2.6 kernel, we should use tgid in task_struct as the process id.
And pid in task_struct should be thread id, although in a single thread
application pid == tgid.

  So the pid() in context.stp should be:

        function pid:long () %{
        if (unlikely(in_interrupt()))
                THIS->__retvalue = 0;
        else
                THIS->__retvalue = current->tgid;
       %}
 
  And we should add a tid() function:
      function tid:long () %{
        if (unlikely(in_interrupt()))
                THIS->__retvalue = 0;
        else
                THIS->__retvalue = current->pid;
      %}


Best Regards,

Li Guanglei

- Linux Performance, China Systems & Technology Lab
China Development Labs, Beijing Tel: 86-10-82782244 Ext.3516  Email:
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: thread id and process id in 2.6 kernel

Frank Ch. Eigler

Guang Lei Li <[hidden email]> writes:

>   In the 2.6 kernel, we should use tgid in task_struct as the process id.
> And pid in task_struct should be thread id, although in a single thread
> application pid == tgid.
> [...]

You're exactly right.  When finding such bugs, it may be best to go
straight to bugzilla, and open a bug against the component in question
("tapset" in this case).  In this case, I'll commit your fix.

- FChE