Re: Process id recycling and status of tasks

From: Clemens Ladisch
Date: Mon Oct 26 2009 - 04:41:51 EST


Leonidas . wrote:
> On Fri, Oct 23, 2009 at 1:43 PM, Clemens Ladisch <clemens@xxxxxxxxxx> wrote:
> > Get a reference to the task's pid (...), then later check whether
> > pid_task() works.
>
> Was going through pid.c, what is the fundamental difference between pid_task()
> and get_pid_task()?

As I said, the functions with "get" in their name increase the reference
count. In other words, get_pid_task(p) is implemented as
get_task(pid_task(p)), so, if it succeeded, you would then own a
reference to the task.

> Now my understanding is get_pid_task() should be followed by put_pid_task()
> so the reference counting work as expected, but put_pid_task() is not an
> exported symbol?

You'd have a standard task_struct, so you'd just use put_task(). And if
you don't actually want a reference to the task (because you only want
to check whether the task still exists), just use pid_task() instead.


HTH
Clemens
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/