All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] RT_TASK descriptor question
@ 2006-03-25  9:47 Alessandro Pittaluga
  2006-03-25 10:07 ` Philippe Gerum
  0 siblings, 1 reply; 2+ messages in thread
From: Alessandro Pittaluga @ 2006-03-25  9:47 UTC (permalink / raw)
  To: xenomai

Hi,

In the native skin rt_task_create receives a pointer to a RT_TASK struct
which must be allocated in permanent memory.
So I thought that the address of this struct would be the task
identifier used to be passed to the other rt_task functions.
And it works in this way.

The strange thing is that rt_task_self does not return the same value of
RT_TASK*, but allocates a new RT_TASK structure the first time it is
called in a new task context.

Why? 

Many thanks

Alessandro
-- 
  Alessandro Pittaluga
  al.pittaluga@domain.hid

-- 
http://www.fastmail.fm - A fast, anti-spam email service.



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Xenomai-help] RT_TASK descriptor question
  2006-03-25  9:47 [Xenomai-help] RT_TASK descriptor question Alessandro Pittaluga
@ 2006-03-25 10:07 ` Philippe Gerum
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Gerum @ 2006-03-25 10:07 UTC (permalink / raw)
  To: Alessandro Pittaluga; +Cc: xenomai

Alessandro Pittaluga wrote:
> Hi,
> 
> In the native skin rt_task_create receives a pointer to a RT_TASK struct
> which must be allocated in permanent memory.
> So I thought that the address of this struct would be the task
> identifier used to be passed to the other rt_task functions.
> And it works in this way.
> 
> The strange thing is that rt_task_self does not return the same value of
> RT_TASK*, but allocates a new RT_TASK structure the first time it is
> called in a new task context.
> 
> Why? 
> 

Because the relevant bit of information is not the descriptor struct per 
se, but rather its contents. This way, one can point to the same object 
using a descriptor struct, regardless of the allocation context of such 
struct. This is particularly useful for sharing objects between 
different execution spaces: regardless of the layout of the descriptor 
or the context it has been created, one only has to know that the 
descriptor contains enough information to point back to the registered 
object; IOW, the descriptor address is not part of the indexing information.

Using this property, rt_task_self() can simply fill any descriptor 
_struct_ once, at the time of the first call for any given thread. The 
struct itself is part of TSD/PTD information, and has been pre-allocated 
at thread creation. This way, the kernel is only asked once for filling 
the struct on a pre-allocated memory area, and subsequent calls to 
rt_task_self() just return the PTD value associated with the descriptor 
struct key.

> Many thanks
> 
> Alessandro


-- 

Philippe.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-03-25 10:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-25  9:47 [Xenomai-help] RT_TASK descriptor question Alessandro Pittaluga
2006-03-25 10:07 ` Philippe Gerum

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.