All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] rt_task_join() small issue on not-joinable task
       [not found] <18922906.201302613837843.JavaMail.SYSTEM@pc-msalvini>
@ 2011-04-12 13:14 ` Mauro Salvini
  2011-04-23 16:05   ` Gilles Chanteperdrix
  0 siblings, 1 reply; 4+ messages in thread
From: Mauro Salvini @ 2011-04-12 13:14 UTC (permalink / raw)
  To: xenomai

Hi to all, 

I'm running Xenomai 2.5.5.2 IPipe 2.7-04 on kernel 2.6.35.7-x86. 

I have a main real time task that creates a thread: this thread calls rt_task_shadow() to turns itself into real-time task 
I discovered this: if I exit from this task and then call rt_task_join() on it from main task, rt_task_join() returns 0 instead -EINVAL as expected (T_JOINABLE flag does not exist for rt_task_shadow() function). Is it correct a behavior? 

Here a simple code to explain it: 

RT_TASK taskHandler; 
pthread_t threadHandler; 
char bContinue; 

void task1 (void *arg) 
{ 
   while( bContinue ) 
   { 
      rt_printf("running\n"); 
      rt_task_sleep(500000000); 
   } 
   rt_printf("exit\n"); 
} 

void * thread1 (void *arg) 
{ 
   int ret=0; 
   rt_printf("shadow:%d\n",(ret=rt_task_shadow(&taskHandler,"Task1",50,0))); 
   if(ret==0) 
      task1(NULL); 
   return NULL; 
} 

int main (int argc, char** argv) 
{ 
   mlockall ( MCL_CURRENT | MCL_FUTURE ); 
   rt_print_auto_init(1); 

   rt_task_shadow(NULL,"Maintask",70,T_JOINABLE); 

   bContinue=1; 
   rt_printf("thread create:%d\n",pthread_create ( &threadHandler , NULL , thread1 , NULL )); 
   rt_task_sleep(2000000000ULL); 
   bContinue=0; 
   rt_printf("join:%d\n",rt_task_join(&taskHandler)); 

   return 0; 
} 

Output is: 

thread create:0 
shadow:0 
running 
running 
running 
running 
exit 
join:0 

I know that rt_task_shadow() wasn't made to create new tasks, it wants to be an example code only. 

Regards 

Mauro 

PS: I discovered this behavior because if I redo immediately pthread_create() call after rt_task_join(), rt_task_shadow() returns -EEXIST (peraphs only if main task has bigger priority than created task: if it has equal or smaller priority, rt_task_shadow() call works fine. But this is another affair). 



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

* Re: [Xenomai-help] rt_task_join() small issue on not-joinable task
  2011-04-12 13:14 ` Mauro Salvini
@ 2011-04-23 16:05   ` Gilles Chanteperdrix
  0 siblings, 0 replies; 4+ messages in thread
From: Gilles Chanteperdrix @ 2011-04-23 16:05 UTC (permalink / raw)
  To: Mauro Salvini; +Cc: xenomai

Mauro Salvini wrote:
> Hi to all,
> 
> I'm running Xenomai 2.5.5.2 IPipe 2.7-04 on kernel 2.6.35.7-x86.
> 
> I have a main real time task that creates a thread: this thread calls
> rt_task_shadow() to turns itself into real-time task I discovered
> this: if I exit from this task and then call rt_task_join() on it
> from main task, rt_task_join() returns 0 instead -EINVAL as expected
> (T_JOINABLE flag does not exist for rt_task_shadow() function). Is it
> correct a behavior?

Why would not it be correct? I mean, Linux threads are joinable by
default, so, it is normal that rt_task_join succeeds. Now, we can
implement a different behaviour, but for what reason?

-- 
                                                                Gilles.


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

* Re: [Xenomai-help] rt_task_join() small issue on not-joinable task
       [not found] <28969746.161303825604578.JavaMail.SYSTEM@pc-msalvini>
@ 2011-04-26 13:47 ` Mauro Salvini
  2011-04-26 18:04   ` Gilles Chanteperdrix
  0 siblings, 1 reply; 4+ messages in thread
From: Mauro Salvini @ 2011-04-26 13:47 UTC (permalink / raw)
  To: xenomai


> Why would not it be correct? I mean, Linux threads are joinable by
> default, so, it is normal that rt_task_join succeeds. Now, we can
> implement a different behaviour, but for what reason?

OK sorry, I wrongly think that rt_task_shadow() follows rt_task_create() behaviour (task was joinable only if T_JOINABLE specified).

Thank you, regards.


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

* Re: [Xenomai-help] rt_task_join() small issue on not-joinable task
  2011-04-26 13:47 ` [Xenomai-help] rt_task_join() small issue on not-joinable task Mauro Salvini
@ 2011-04-26 18:04   ` Gilles Chanteperdrix
  0 siblings, 0 replies; 4+ messages in thread
From: Gilles Chanteperdrix @ 2011-04-26 18:04 UTC (permalink / raw)
  To: Mauro Salvini; +Cc: xenomai

Mauro Salvini wrote:
>> Why would not it be correct? I mean, Linux threads are joinable by 
>> default, so, it is normal that rt_task_join succeeds. Now, we can 
>> implement a different behaviour, but for what reason?
> 
> OK sorry, I wrongly think that rt_task_shadow() follows
> rt_task_create() behaviour (task was joinable only if T_JOINABLE
> specified).

The T_JOINABLE bit is not documented for rt_task_shadow. So, any
behaviour is valid. But as I said, we can add it.

> 
> Thank you, regards.
> 
> _______________________________________________ Xenomai-help mailing
> list Xenomai-help@domain.hid https://mail.gna.org/listinfo/xenomai-help
> 


-- 
                                                                Gilles.


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

end of thread, other threads:[~2011-04-26 18:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <28969746.161303825604578.JavaMail.SYSTEM@pc-msalvini>
2011-04-26 13:47 ` [Xenomai-help] rt_task_join() small issue on not-joinable task Mauro Salvini
2011-04-26 18:04   ` Gilles Chanteperdrix
     [not found] <18922906.201302613837843.JavaMail.SYSTEM@pc-msalvini>
2011-04-12 13:14 ` Mauro Salvini
2011-04-23 16:05   ` Gilles Chanteperdrix

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.