All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Jan Kiszka <jan.kiszka@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] What returns rt_task_self in relation	to	rt_task_create
Date: Wed, 22 Nov 2006 15:00:35 +0100	[thread overview]
Message-ID: <1164204035.5006.305.camel@domain.hid> (raw)
In-Reply-To: <45644D39.10007@domain.hid>

On Wed, 2006-11-22 at 14:14 +0100, Jan Kiszka wrote:

[...]

> >>> How are those addresses related - how can I find out the descriptor address 
> >>> used for rt_task_create() at runtime?
> >> The documentation is not precise enough here: what you obtain from
> >> rt_task_self is /some/ task descriptor for the currently running task,
> >> it is not a reference to the same piece of memory containing the task
> >> descriptor. Check the library implementation for further insights.
> >>
> > 
> > A descriptor should always be seen as a reference to an object, not as
> > the object itself. Said differently, there is no such thing as a
> > main/unique/specific descriptor for any given object. The doc says
> > exactly that: you get a valid descriptor to the task by calling
> > rt_task_self(), but nothing says that this ought to be the unique way of
> > referencing it. 
> 
> The doc talks quite a lot about "_the_ task descriptor address" which
> /may/ suggest to the reader that there is only one address. That this
> cannot be the case becomes obvious when considering user/kernel or
> cross-process usage. Still, clarification at some point can help to
> avoid any future misinterpretation.
> 
> Suggestion (rt_task_self):
> 
> "Return the address of a descriptor for the current task.
> 

Agreed.

> Note: The returned descriptor address does not relate to the descriptor
> address passed to rt_task_create or similar services."
> 

Well, it actually does in intra-kernel calls, where rt_task_self()
returns the container object of the base nucleus thread present in the
RT_TASK struct the user passed us, even if nobody should rely on this
fact. I would try to clear any confusion like this:
"The address returned points at a descriptor identifying the calling
task, which might be different from the descriptor address passed to
rt_task_create()."

> Jan
> 
> 
> PS: Who's supposed to free the descriptor allocated by rt_task_self?
> Would some check for pthread_getspecific(__native_tskey) + free() on
> task self-destruction make sense? Will not catch all cases, I know.
> 

We could add that, and the same stuff upon return from the task body
inside the trampoline call, but the only way to solve this with no leak
would be to call the nucleus at each invocation, and not use any cached
descriptor here. Since TLS requires to be operated by the owning task,
there is no point in trying to have a deleted task clean those up
thoroughly.

-- 
Philippe.




  reply	other threads:[~2006-11-22 14:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-22 11:38 [Xenomai-help] What returns rt_task_self in relation to rt_task_create M. Koehrer
2006-11-22 12:04 ` Jan Kiszka
2006-11-22 12:52   ` Philippe Gerum
2006-11-22 13:14     ` Jan Kiszka
2006-11-22 14:00       ` Philippe Gerum [this message]
2006-11-22 14:03         ` Gilles Chanteperdrix
2006-11-22 14:22           ` Philippe Gerum
2006-11-22 16:34             ` Gilles Chanteperdrix
2006-11-22 17:03               ` Philippe Gerum
2006-11-22 17:38                 ` Gilles Chanteperdrix
2006-11-22 18:33                   ` Philippe Gerum
2006-11-22 14:16         ` Re: [Xenomai-help] What returns rt_task_self in M. Koehrer
2006-11-22 14:33           ` Jan Kiszka
2006-11-22 14:49           ` Philippe Gerum
2006-11-22 13:09 ` [Xenomai-help] What returns rt_task_self in relation to rt_task_create Philippe Gerum
2006-11-22 13:48   ` [Xenomai-help] What returns rt_task_self in relation tort_task_create Daniel Schnell
2006-11-22 14:06     ` Jan Kiszka
2006-11-22 14:16     ` Philippe Gerum
2006-11-22 14:23       ` Philippe Gerum

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=1164204035.5006.305.camel@domain.hid \
    --to=rpm@xenomai.org \
    --cc=jan.kiszka@domain.hid \
    --cc=xenomai@xenomai.org \
    /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.