All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Love <rml@ximian.com>
To: Fabiano Ramos <ramos_fabiano@yahoo.com.br>
Cc: linux-kernel@vger.kernel.org
Subject: Re: get_task_struct()
Date: Sat, 17 Apr 2004 12:19:50 -0400	[thread overview]
Message-ID: <1082218790.10360.6.camel@localhost> (raw)
In-Reply-To: <1082216800.1447.26.camel@slack.domain.invalid>

On Sat, 2004-04-17 at 12:46 -0300, Fabiano Ramos wrote:

> Inside sys_ptrace, the function get_task_struct is invoked after
> retrieving the child's task srtuct pointer. Why is it done? I have
> tracked down the code and noticed that it is in fact an increment
> on the (page?) counter. Can you help me understand it? 

Think of get_task_struct(foo) as a reference count on foo's task
structure.  So long as the reference count is elevated, foo's task
structure cannot be deallocated.

get_task_struct() is called here because sys_ptrace() needs to ensure
that the child's task structure does not go away out from under this
function, but we do not want to hold the tasklist_lock.

> Is it necessary to call free_task_struct whenever its get counterpart
> is called?

Yes, although it is called "put_task_struct()".  It is called at the end
of this function.

	Robert Love



      reply	other threads:[~2004-04-17 16:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-17 15:46 get_task_struct() Fabiano Ramos
2004-04-17 16:19 ` Robert Love [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1082218790.10360.6.camel@localhost \
    --to=rml@ximian.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ramos_fabiano@yahoo.com.br \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.