All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Salvini <mauro.salvini@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-help] rt_task_join() small issue on not-joinable task
Date: Tue, 12 Apr 2011 15:14:53 +0200 (CEST)	[thread overview]
Message-ID: <537545.221302614089218.JavaMail.SYSTEM@pc-msalvini> (raw)
In-Reply-To: <18922906.201302613837843.JavaMail.SYSTEM@pc-msalvini>

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). 



       reply	other threads:[~2011-04-12 13:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <18922906.201302613837843.JavaMail.SYSTEM@pc-msalvini>
2011-04-12 13:14 ` Mauro Salvini [this message]
2011-04-23 16:05   ` [Xenomai-help] rt_task_join() small issue on not-joinable task Gilles Chanteperdrix
     [not found] <28969746.161303825604578.JavaMail.SYSTEM@pc-msalvini>
2011-04-26 13:47 ` Mauro Salvini
2011-04-26 18:04   ` Gilles Chanteperdrix

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=537545.221302614089218.JavaMail.SYSTEM@pc-msalvini \
    --to=mauro.salvini@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.