All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johann Obermayr <johann.obermayr@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-help] rt_task_delete trouble
Date: Fri, 11 Mar 2011 09:28:34 +0100	[thread overview]
Message-ID: <4D79DD32.4050307@domain.hid> (raw)

[-- Attachment #1: Type: text/plain, Size: 3527 bytes --]

Hello,

i'm a newbie with xenomai.
My problem is, if a rt task will delete with rt_task_delete, than
the progam hangs.

here is my sample
----------------------------------
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>

#include <native/mutex.h>
#include <native/task.h>
#include <native/types.h>

#include <rtdk.h>

RT_TASK task_waiter, task_worker;

volatile int task_waiter_flag = 0;

#define DELAYS(x)        (x * 1000 * 1000 * 1000)
#define DELAYMS(x)        (x * 1000 * 1000)

void delaysec(unsigned int sec)
{
     RTIME delay = DELAYS(sec);
     rt_task_sleep( delay );
}

void task_waiter_do(void *data)
{
     rt_printf("task_waiter_do started\n");
     while(task_waiter_flag == 0)
         ; // rt_task_sleep( DELAYMS(1) );
     rt_printf("task_waiter_do finished\n");
}

void task_worker_do(void *data)
{
     int rval;
     rt_printf("task_worker_do started\n");
     delaysec(1);
     rt_printf("task_worker_do suspend waiter\n");
     rval = rt_task_suspend(&task_waiter);
     rt_printf("task_worker_do suspend:%d\n", rval);
     delaysec(1);
     rt_printf("task_worker_do delete waiter\n");
     rval = rt_task_delete(&task_waiter);
     rt_printf("task_worker_do delete:%d\n", rval);
     delaysec(1);
     while(task_waiter_flag == 0)
         rt_task_sleep( DELAYMS(10) );
     rt_printf("task_worker_do finished\n");
}

int main(int argc, char **argv)
{
     int rval;

     mlockall(MCL_CURRENT|MCL_FUTURE);

     printf("Starting\n");
     rt_print_auto_init(1);

     rval = rt_task_create(&task_worker, "worker", 0, 80, 0);
     if (rval == 0) {
         rval = rt_task_create(&task_waiter, "waiter", 0, 30, 0);

         rval = rt_task_start(&task_worker, &task_worker_do, NULL);
         if (rval == 0) {
             rval = rt_task_start(&task_waiter, &task_waiter_do, NULL);
             if (rval == 0) {

                 printf("Working\n");
             }
             else
                 rt_printf("rt_task_suspend failed(%d)", rval);
         }
         else
             rt_printf("rt_task_start failed(%d)", rval);
     }
     else
         rt_printf("rt_task_create failed(%d)", rval);


     printf("Finsihed <press any key>\n");
     getchar();
     task_waiter_flag = 1;
     usleep(100000);
     return 0;
}
----------------------------------
the task task_worker_do will hang after rt_task_delete. Why ?
if i add a sleep into task_waiter_do, the sample work correct.
What can i do, to solve this.

   Thanks
     greetings
       Johann

-- 
Mit freundlichen Grüßen, best regards
     Johann Obermayr

Software Entwicklung
________________________________________________
SIGMATEK GmbH&  Co KG
Sigmatekstraße 1
5112 Lamprechtshausen
Österreich / Austria

Tel.  :  +43 / 6274/ 43 21-0   (Durchwahl leider nicht möglich)
Fax   :  +43 / 6274/ 43 21-18  (bzw 300 im Werk 2 )
E-Mail:johann.obermayr@domain.hid
http://www.sigmatek-automation.com
****************************Please note:********************************
  This email and all attachments are confidential and intended solely for
  the person or entity to whom it is addressed. If you are not the named
  addressee you must not make this email and all attachments accessible
  to any other person. If you have received this email in error please
  delete it together with all attachments.
************************************************************************


[-- Attachment #2: Type: text/html, Size: 5267 bytes --]

             reply	other threads:[~2011-03-11  8:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-11  8:28 Johann Obermayr [this message]
2011-03-11  8:51 ` [Xenomai-help] rt_task_delete trouble Gilles Chanteperdrix
2011-03-11  8:58   ` Jan Kiszka
2011-03-11  9:06     ` Gilles Chanteperdrix
2011-03-11  9:59     ` Johann Obermayr
2011-03-11  9:52   ` Johann Obermayr
2011-03-11  9:56     ` Gilles Chanteperdrix
2011-03-11 13:13     ` Gilles Chanteperdrix
2011-03-11 10:59   ` Johann Obermayr

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=4D79DD32.4050307@domain.hid \
    --to=johann.obermayr@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.