From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4D79DD32.4050307@domain.hid> Date: Fri, 11 Mar 2011 09:28:34 +0100 From: Johann Obermayr MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------090306070204090704010909" Subject: [Xenomai-help] rt_task_delete trouble Reply-To: johann.obermayr@domain.hid List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: xenomai@xenomai.org This is a multi-part message in MIME format. --------------090306070204090704010909 Content-Type: text/plain; charset="iso-8859-15"; format="flowed" Content-Transfer-Encoding: quoted-printable 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 #include #include #include #include #include #include #include RT_TASK task_waiter, task_worker; volatile int task_waiter_flag =3D 0; #define DELAYS(x) (x * 1000 * 1000 * 1000) #define DELAYMS(x) (x * 1000 * 1000) void delaysec(unsigned int sec) { RTIME delay =3D DELAYS(sec); rt_task_sleep( delay ); } void task_waiter_do(void *data) { rt_printf("task_waiter_do started\n"); while(task_waiter_flag =3D=3D 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 =3D 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 =3D rt_task_delete(&task_waiter); rt_printf("task_worker_do delete:%d\n", rval); delaysec(1); while(task_waiter_flag =3D=3D 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 =3D rt_task_create(&task_worker, "worker", 0, 80, 0); if (rval =3D=3D 0) { rval =3D rt_task_create(&task_waiter, "waiter", 0, 30, 0); rval =3D rt_task_start(&task_worker, &task_worker_do, NULL); if (rval =3D=3D 0) { rval =3D rt_task_start(&task_waiter, &task_waiter_do, NULL); if (rval =3D=3D 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 \n"); getchar(); task_waiter_flag =3D 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 --=20 Mit freundlichen Gr=FC=DFen, best regards Johann Obermayr Software Entwicklung ________________________________________________ SIGMATEK GmbH& Co KG Sigmatekstra=DFe 1 5112 Lamprechtshausen =D6sterreich / Austria Tel. : +43 / 6274/ 43 21-0 (Durchwahl leider nicht m=F6glich) 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. ************************************************************************ --------------090306070204090704010909 Content-Type: text/html; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable
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 =3D 0;

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

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

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

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

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

=A0=A0=A0 mlockall(MCL_CURRENT|MCL_FUTURE);

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

=A0=A0=A0 rval =3D rt_task_create(&task_worker, "worker", 0, 80, = 0);
=A0=A0=A0 if (rval =3D=3D 0) {
=A0=A0=A0=A0=A0=A0=A0 rval =3D rt_task_create(&task_waiter, "wait= er", 0, 30, 0);

=A0=A0=A0=A0=A0=A0=A0 rval =3D rt_task_start(&task_worker, &task_worker_do, NULL);
=A0=A0=A0=A0=A0=A0=A0 if (rval =3D=3D 0) {
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 rval =3D rt_task_start(&task_wa= iter, &task_waiter_do, NULL);
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (rval =3D=3D 0) {

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 printf("Working\n"); =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 }
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 else
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 rt_printf("rt_task_susp= end failed(%d)", rval);
=A0=A0=A0=A0=A0=A0=A0 }
=A0=A0=A0=A0=A0=A0=A0 else
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 rt_printf("rt_task_start failed(%d)= ", rval);
=A0=A0=A0 }
=A0=A0=A0 else
=A0=A0=A0=A0=A0=A0=A0 rt_printf("rt_task_create failed(%d)", rval); <= br>

=A0=A0=A0 printf("Finsihed <press any key>\n");
=A0=A0=A0 getchar();
=A0=A0=A0 task_waiter_flag =3D 1;
=A0=A0=A0 usleep(100000);
=A0=A0=A0 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.

=A0 Thanks
=A0=A0=A0 greetings
=A0=A0=A0=A0=A0 Johann

--=20
Mit freundlichen Gr=FC=DFen, best regards
    Johann Obermayr

Software Entwicklung
________________________________________________
SIGMATEK GmbH & Co KG
Sigmatekstra=DFe 1
5112 Lamprechtshausen
=D6sterreich / Austria

Tel.  :  +43 / 6274/ 43 21-0   (Durchwahl leider nicht m=F6glich)
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.
************************************************************************
--------------090306070204090704010909--