All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] RT_QUEUE problem in Sender/Receiver order
@ 2010-04-19 17:01 Michel He
  2010-04-19 17:04 ` Gilles Chanteperdrix
  2010-04-19 17:16 ` Philippe Gerum
  0 siblings, 2 replies; 7+ messages in thread
From: Michel He @ 2010-04-19 17:01 UTC (permalink / raw)
  To: xenomai

hello everyone,

    I find out a problem (it seems already mentionned before but I  
can't find the link to the forum and the post). It deals with the  
message passing, eg. when we change the order of task execution,  
something can get wrong. Notice that codes below, if we launch the  
exection of Recep2,Recep3,Sender, Recep2 won't get the right message.  
But if we change the order to : Sender,Recep2,Recep3, everything is  
back to OK. So any explanation ?


	err = rt_task_spawn(&test_task2_ptr, "Recep2", STACK_SIZE, STD_PRIO,  
0, &testtask2, NULL);
	if (err) {
		rt_printf("error rt_task_spawn 2\n");
		return 0;
	}
	recvTask[nrecvhost]=&test_task2_ptr;

	err =  
rt_queue_create(&(recvCanal[nrecvhost]),"Recep2CANAL",MAX_MESSAGE_LENGTH,  
QUEUE_LIM, Q_FIFO);

	if (err) {
		rt_printf("error RT_canal_create 2 \n");
		return 0;
	}
	nrecvhost++;


	err = rt_task_spawn(&test_task3_ptr, "Recep3", STACK_SIZE, STD_PRIO,  
0, &testtask3, NULL);
	if (err) {
		rt_printf("error rt_task_spawn 3\n");
		return 0;
	}
	recvTask[nrecvhost]=&test_task3_ptr;

	err =  
rt_queue_create(&(recvCanal[nrecvhost]),"Recep3CANAL",MAX_MESSAGE_LENGTH,  
QUEUE_LIM, Q_FIFO);

	if (err) {
		rt_printf("error RT_canal_create 2 \n");
		return 0;

	}
	nrecvhost++;


	err = rt_task_spawn(&test_task_ptr, "Sender", STACK_SIZE, STD_PRIO,  
0, &testtask, NULL);
	if (err) {
		rt_printf("error rt_task_spawn\n");
		return 0;
	}
	recvTask[nrecvhost]=&test_task_ptr;
	nrecvhost++;



testtask2()
{
...
rcbytes=RT_queue_read(&(recvCanal[0]),&rcvmsg,sizeof(rcvmsg),TM_INFINITE);
}


testtask3()
{
...
rcbytes=RT_queue_read(&(recvCanal[1]),&rcvmsg,sizeof(rcvmsg),TM_INFINITE);
}


thank you




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

* Re: [Xenomai-help] RT_QUEUE problem in Sender/Receiver order
  2010-04-19 17:01 [Xenomai-help] RT_QUEUE problem in Sender/Receiver order Michel He
@ 2010-04-19 17:04 ` Gilles Chanteperdrix
  2010-04-20 15:21   ` Michel He
  2010-04-19 17:16 ` Philippe Gerum
  1 sibling, 1 reply; 7+ messages in thread
From: Gilles Chanteperdrix @ 2010-04-19 17:04 UTC (permalink / raw)
  To: Michel He; +Cc: xenomai

Michel He wrote:
> hello everyone,
> 
>     I find out a problem (it seems already mentionned before but I  
> can't find the link to the forum and the post). It deals with the  
> message passing, eg. when we change the order of task execution,  
> something can get wrong. Notice that codes below, if we launch the  
> exection of Recep2,Recep3,Sender, Recep2 won't get the right message.  
> But if we change the order to : Sender,Recep2,Recep3, everything is  
> back to OK. So any explanation ?

A piece of self-contained code, compiling and demonstrating a bug when
running is worth a thousand words.


-- 
					    Gilles.


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

* Re: [Xenomai-help] RT_QUEUE problem in Sender/Receiver order
  2010-04-19 17:01 [Xenomai-help] RT_QUEUE problem in Sender/Receiver order Michel He
  2010-04-19 17:04 ` Gilles Chanteperdrix
@ 2010-04-19 17:16 ` Philippe Gerum
  2010-04-20  4:46   ` Josh Bowman
  1 sibling, 1 reply; 7+ messages in thread
From: Philippe Gerum @ 2010-04-19 17:16 UTC (permalink / raw)
  To: Michel He; +Cc: xenomai

On Mon, 2010-04-19 at 19:01 +0200, Michel He wrote:
> hello everyone,
> 
>     I find out a problem (it seems already mentionned before but I  
> can't find the link to the forum and the post).

Ok. In the same vein, it turns out that you might be right, but I could
not find the link to the post that says so.

>  It deals with the  
> message passing, eg. when we change the order of task execution,  
> something can get wrong. Notice that codes below, if we launch the  
> exection of Recep2,Recep3,Sender, Recep2 won't get the right message.  
> But if we change the order to : Sender,Recep2,Recep3, everything is  
> back to OK. So any explanation ?

Any explanation from your end about what you would consider as a correct
result from that code, or should we resort to our well-known psychic
power to find it?

> 
> 
> 	err = rt_task_spawn(&test_task2_ptr, "Recep2", STACK_SIZE, STD_PRIO,  
> 0, &testtask2, NULL);
> 	if (err) {
> 		rt_printf("error rt_task_spawn 2\n");
> 		return 0;
> 	}
> 	recvTask[nrecvhost]=&test_task2_ptr;
> 
> 	err =  
> rt_queue_create(&(recvCanal[nrecvhost]),"Recep2CANAL",MAX_MESSAGE_LENGTH,  
> QUEUE_LIM, Q_FIFO);
> 
> 	if (err) {
> 		rt_printf("error RT_canal_create 2 \n");
> 		return 0;
> 	}
> 	nrecvhost++;
> 
> 
> 	err = rt_task_spawn(&test_task3_ptr, "Recep3", STACK_SIZE, STD_PRIO,  
> 0, &testtask3, NULL);
> 	if (err) {
> 		rt_printf("error rt_task_spawn 3\n");
> 		return 0;
> 	}
> 	recvTask[nrecvhost]=&test_task3_ptr;
> 
> 	err =  
> rt_queue_create(&(recvCanal[nrecvhost]),"Recep3CANAL",MAX_MESSAGE_LENGTH,  
> QUEUE_LIM, Q_FIFO);
> 
> 	if (err) {
> 		rt_printf("error RT_canal_create 2 \n");
> 		return 0;
> 
> 	}
> 	nrecvhost++;
> 
> 
> 	err = rt_task_spawn(&test_task_ptr, "Sender", STACK_SIZE, STD_PRIO,  
> 0, &testtask, NULL);
> 	if (err) {
> 		rt_printf("error rt_task_spawn\n");
> 		return 0;
> 	}
> 	recvTask[nrecvhost]=&test_task_ptr;
> 	nrecvhost++;
> 
> 
> 
> testtask2()
> {
> ...
> rcbytes=RT_queue_read(&(recvCanal[0]),&rcvmsg,sizeof(rcvmsg),TM_INFINITE);
> }
> 
> 
> testtask3()
> {
> ...
> rcbytes=RT_queue_read(&(recvCanal[1]),&rcvmsg,sizeof(rcvmsg),TM_INFINITE);
> }
> 
> 
> thank you
> 
> 
> 
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@domain.hid
> https://mail.gna.org/listinfo/xenomai-help


-- 
Philippe.




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

* Re: [Xenomai-help] RT_QUEUE problem in Sender/Receiver order
  2010-04-19 17:16 ` Philippe Gerum
@ 2010-04-20  4:46   ` Josh Bowman
  2010-04-20  8:22     ` Philippe Gerum
  0 siblings, 1 reply; 7+ messages in thread
From: Josh Bowman @ 2010-04-20  4:46 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: xenomai, Michel He

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

Hi,

I'm reluctant to jump in here with my own notably limited psychic powers,
but I did notice that the code given spawns the receiving tasks before it
creates the queues that they receive from.  This would create a race
condition (if a STD_PRIO task can preempt the task that's doing the
initialization.)

-Josh

On Mon, Apr 19, 2010 at 1:16 PM, Philippe Gerum <rpm@xenomai.org> wrote:

> On Mon, 2010-04-19 at 19:01 +0200, Michel He wrote:
> >
> >       err = rt_task_spawn(&test_task2_ptr, "Recep2", STACK_SIZE,
> STD_PRIO,
> > 0, &testtask2, NULL);
> >       if (err) {
> >               rt_printf("error rt_task_spawn 2\n");
> >               return 0;
> >       }
> >       recvTask[nrecvhost]=&test_task2_ptr;
> >
> >       err =
> > rt_queue_create(&(recvCanal[nrecvhost]),"Recep2CANAL",MAX_MESSAGE_LENGTH,
> > QUEUE_LIM, Q_FIFO);
> >
> >       if (err) {
> >               rt_printf("error RT_canal_create 2 \n");
> >               return 0;
> >       }
> >       nrecvhost++;
> >
> >
> >       err = rt_task_spawn(&test_task3_ptr, "Recep3", STACK_SIZE,
> STD_PRIO,
> > 0, &testtask3, NULL);
> >       if (err) {
> >               rt_printf("error rt_task_spawn 3\n");
> >               return 0;
> >       }
> >       recvTask[nrecvhost]=&test_task3_ptr;
> >
> >       err =
> > rt_queue_create(&(recvCanal[nrecvhost]),"Recep3CANAL",MAX_MESSAGE_LENGTH,
> > QUEUE_LIM, Q_FIFO);
> >
> >       if (err) {
> >               rt_printf("error RT_canal_create 2 \n");
> >               return 0;
> >
> >       }
> >       nrecvhost++;
> >
> >
> >       err = rt_task_spawn(&test_task_ptr, "Sender", STACK_SIZE, STD_PRIO,
> > 0, &testtask, NULL);
> >       if (err) {
> >               rt_printf("error rt_task_spawn\n");
> >               return 0;
> >       }
> >       recvTask[nrecvhost]=&test_task_ptr;
> >       nrecvhost++;
> >
> >
> >
> > testtask2()
> > {
> > ...
> >
> rcbytes=RT_queue_read(&(recvCanal[0]),&rcvmsg,sizeof(rcvmsg),TM_INFINITE);
> > }
> >
> >
> > testtask3()
> > {
> > ...
> >
> rcbytes=RT_queue_read(&(recvCanal[1]),&rcvmsg,sizeof(rcvmsg),TM_INFINITE);
> > }
> >
>

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

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

* Re: [Xenomai-help] RT_QUEUE problem in Sender/Receiver order
  2010-04-20  4:46   ` Josh Bowman
@ 2010-04-20  8:22     ` Philippe Gerum
  2010-04-20 10:20       ` Michel He
  0 siblings, 1 reply; 7+ messages in thread
From: Philippe Gerum @ 2010-04-20  8:22 UTC (permalink / raw)
  To: Josh Bowman; +Cc: xenomai, Michel He

On Tue, 2010-04-20 at 00:46 -0400, Josh Bowman wrote:
> Hi,
> 
> I'm reluctant to jump in here with my own notably limited psychic
> powers, but I did notice that the code given spawns the receiving
> tasks before it creates the queues that they receive from.  This would
> create a race condition (if a STD_PRIO task can preempt the task
> that's doing the initialization.)
> 

You are likely right, priority issues are usually involved in that
scenario, particularly since the initiator of all those creation calls
is the low-priority root thread.

> -Josh
> 
> On Mon, Apr 19, 2010 at 1:16 PM, Philippe Gerum <rpm@xenomai.org>
> wrote:
>         On Mon, 2010-04-19 at 19:01 +0200, Michel He wrote:
>         
>         >
>         >       err = rt_task_spawn(&test_task2_ptr, "Recep2",
>         STACK_SIZE, STD_PRIO,
>         > 0, &testtask2, NULL);
>         >       if (err) {
>         >               rt_printf("error rt_task_spawn 2\n");
>         >               return 0;
>         >       }
>         >       recvTask[nrecvhost]=&test_task2_ptr;
>         >
>         >       err =
>         >
>         rt_queue_create(&(recvCanal[nrecvhost]),"Recep2CANAL",MAX_MESSAGE_LENGTH,
>         > QUEUE_LIM, Q_FIFO);
>         >
>         >       if (err) {
>         >               rt_printf("error RT_canal_create 2 \n");
>         >               return 0;
>         >       }
>         >       nrecvhost++;
>         >
>         >
>         >       err = rt_task_spawn(&test_task3_ptr, "Recep3",
>         STACK_SIZE, STD_PRIO,
>         > 0, &testtask3, NULL);
>         >       if (err) {
>         >               rt_printf("error rt_task_spawn 3\n");
>         >               return 0;
>         >       }
>         >       recvTask[nrecvhost]=&test_task3_ptr;
>         >
>         >       err =
>         >
>         rt_queue_create(&(recvCanal[nrecvhost]),"Recep3CANAL",MAX_MESSAGE_LENGTH,
>         > QUEUE_LIM, Q_FIFO);
>         >
>         >       if (err) {
>         >               rt_printf("error RT_canal_create 2 \n");
>         >               return 0;
>         >
>         >       }
>         >       nrecvhost++;
>         >
>         >
>         >       err = rt_task_spawn(&test_task_ptr, "Sender",
>         STACK_SIZE, STD_PRIO,
>         > 0, &testtask, NULL);
>         >       if (err) {
>         >               rt_printf("error rt_task_spawn\n");
>         >               return 0;
>         >       }
>         >       recvTask[nrecvhost]=&test_task_ptr;
>         >       nrecvhost++;
>         >
>         >
>         >
>         > testtask2()
>         > {
>         > ...
>         >
>         rcbytes=RT_queue_read(&(recvCanal[0]),&rcvmsg,sizeof(rcvmsg),TM_INFINITE);
>         > }
>         >
>         >
>         > testtask3()
>         > {
>         > ...
>         >
>         rcbytes=RT_queue_read(&(recvCanal[1]),&rcvmsg,sizeof(rcvmsg),TM_INFINITE);
>         > }
>         >
>         
> 


-- 
Philippe.




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

* Re: [Xenomai-help] RT_QUEUE problem in Sender/Receiver order
  2010-04-20  8:22     ` Philippe Gerum
@ 2010-04-20 10:20       ` Michel He
  0 siblings, 0 replies; 7+ messages in thread
From: Michel He @ 2010-04-20 10:20 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: xenomai


I firstly thought in xenomai the rt_queue couldn't be simulatenously  
written and read by 2 process, because of the reservation is cancelled  
during the occupancy of the queue. but actually not sure about it, so  
I changed slightly my codes (without adding semaphore though), and  
everything is right now.

thank you anyways

Philippe Gerum <rpm@xenomai.org> a écrit :

> On Tue, 2010-04-20 at 00:46 -0400, Josh Bowman wrote:
>> Hi,
>>
>> I'm reluctant to jump in here with my own notably limited psychic
>> powers, but I did notice that the code given spawns the receiving
>> tasks before it creates the queues that they receive from.  This would
>> create a race condition (if a STD_PRIO task can preempt the task
>> that's doing the initialization.)
>>
>
> You are likely right, priority issues are usually involved in that
> scenario, particularly since the initiator of all those creation calls
> is the low-priority root thread.
>
>> -Josh
>>
>> On Mon, Apr 19, 2010 at 1:16 PM, Philippe Gerum <rpm@xenomai.org>
>> wrote:
>>         On Mon, 2010-04-19 at 19:01 +0200, Michel He wrote:
>>
>>         >
>>         >       err = rt_task_spawn(&test_task2_ptr, "Recep2",
>>         STACK_SIZE, STD_PRIO,
>>         > 0, &testtask2, NULL);
>>         >       if (err) {
>>         >               rt_printf("error rt_task_spawn 2\n");
>>         >               return 0;
>>         >       }
>>         >       recvTask[nrecvhost]=&test_task2_ptr;
>>         >
>>         >       err =
>>         >
>>          
>> rt_queue_create(&(recvCanal[nrecvhost]),"Recep2CANAL",MAX_MESSAGE_LENGTH,
>>         > QUEUE_LIM, Q_FIFO);
>>         >
>>         >       if (err) {
>>         >               rt_printf("error RT_canal_create 2 \n");
>>         >               return 0;
>>         >       }
>>         >       nrecvhost++;
>>         >
>>         >
>>         >       err = rt_task_spawn(&test_task3_ptr, "Recep3",
>>         STACK_SIZE, STD_PRIO,
>>         > 0, &testtask3, NULL);
>>         >       if (err) {
>>         >               rt_printf("error rt_task_spawn 3\n");
>>         >               return 0;
>>         >       }
>>         >       recvTask[nrecvhost]=&test_task3_ptr;
>>         >
>>         >       err =
>>         >
>>          
>> rt_queue_create(&(recvCanal[nrecvhost]),"Recep3CANAL",MAX_MESSAGE_LENGTH,
>>         > QUEUE_LIM, Q_FIFO);
>>         >
>>         >       if (err) {
>>         >               rt_printf("error RT_canal_create 2 \n");
>>         >               return 0;
>>         >
>>         >       }
>>         >       nrecvhost++;
>>         >
>>         >
>>         >       err = rt_task_spawn(&test_task_ptr, "Sender",
>>         STACK_SIZE, STD_PRIO,
>>         > 0, &testtask, NULL);
>>         >       if (err) {
>>         >               rt_printf("error rt_task_spawn\n");
>>         >               return 0;
>>         >       }
>>         >       recvTask[nrecvhost]=&test_task_ptr;
>>         >       nrecvhost++;
>>         >
>>         >
>>         >
>>         > testtask2()
>>         > {
>>         > ...
>>         >
>>          
>> rcbytes=RT_queue_read(&(recvCanal[0]),&rcvmsg,sizeof(rcvmsg),TM_INFINITE);
>>         > }
>>         >
>>         >
>>         > testtask3()
>>         > {
>>         > ...
>>         >
>>          
>> rcbytes=RT_queue_read(&(recvCanal[1]),&rcvmsg,sizeof(rcvmsg),TM_INFINITE);
>>         > }
>>         >
>>
>>
>
>
> --
> Philippe.
>
>
>




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

* Re: [Xenomai-help] RT_QUEUE problem in Sender/Receiver order
  2010-04-19 17:04 ` Gilles Chanteperdrix
@ 2010-04-20 15:21   ` Michel He
  0 siblings, 0 replies; 7+ messages in thread
From: Michel He @ 2010-04-20 15:21 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai

Re,

    In order to describe it (by thousand words as the proverbe said),  
I attach the following example.
You notice that in the line 85 :
rv = rt_task_send(&test_task3_ptr,&mcb_send,&mcb_reply,task_period_ns);

whenever you change &test_task3_ptr to &test_task2_ptr, the message is  
NOT delivered at all. Only task3 can receive good msg. (not task2)

thank you


/*
  * tasksend.c
  *
  *  Created on: 7 avr. 2010
  *      Author: hemichel
  */

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/io.h>
#include <sys/mman.h>
#include <native/task.h>
#include <native/queue.h>
#include <native/intr.h>

#define STACK_SIZE 8192
#define STD_PRIO 1


#define MAXRECVTASK 0
#define ANYSRC 0
#define MAX_MESSAGE_LENGTH 4
#define QUEUE_LIM 512
#define PROBECODE 0xa

RT_TASK test_task_ptr,test_task2_ptr,test_task3_ptr;

//tache maintenant la liste recvhostlist
RT_TASK *recvTask[MAXRECVTASK];
unsigned int nrecvhost=0;

int int_count = 0;
int end = 0;

//delay reception 0.1 s
#define PEER_RATE_NS 100000000

//cycle de la tache d'emission
//                     --s-ms-us-ns
RTIME task_period_ns =   1000000000llu;



void testtask(void *cookie) {
	RT_TASK_MCB mcb_send, mcb_reply;
	int flowid, i, rv;
	unsigned char datasend[16];
	unsigned char datareply[16];

	int count = 0;
	int ret;
	unsigned long overrun;
	ret = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(task_period_ns));
	if (ret) {
		rt_printf("error while set periodic, code %d\n",ret);
		return;
	}

	mcb_send.opcode = 0x03;
	datasend[0]='a';
	mcb_send.data = datasend;
	mcb_send.size = sizeof(datasend);

	mcb_reply.size = sizeof(datareply);
	mcb_reply.data = datareply;

	while(!end){

		if (ret) {
			rt_printf("error while rt_task_set_mode, code %d\n",ret);
			return;
		}
		ret = rt_task_wait_period(&overrun);
		if (ret) {
			rt_printf("error while rt_task_wait_period, code %d\n",ret);
			return;
		}
		count++;
		rt_printf("message from testtask: count=%d\n", count);

		rv = rt_task_send(&test_task3_ptr,&mcb_send,&mcb_reply,task_period_ns);
		if (rv < 0) rt_printf("rt_task_send error\n");
		else rt_printf("get mcb_reply=%d\n",mcb_reply.data[0]);
		fflush(NULL);
	}
}


void testtask2(void *cookie) {
	RT_TASK_MCB mcb_rcv, mcb_reply;
	int flowid, i, rv;
	unsigned char datareply[16];
	unsigned int taskmsg;
	int count = 0;
	int ret;
	unsigned long overrun;
	ret = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(task_period_ns));
	if (ret) {
		rt_printf("error while set periodic, code %d\n",ret);
		return;
	}

	while(!end){

		ret = rt_task_wait_period(&overrun);
		if (ret) {
			rt_printf("error while rt_task_wait_period, code %d\n",ret);
			return;
		}

		mcb_rcv.data = (caddr_t)&datareply;
		mcb_rcv.size = sizeof(datareply);

		flowid = rt_task_receive(&mcb_rcv,PEER_RATE_NS);
		rt_printf("%s flowid=%d opcode=%d\n",\
				__FUNCTION__, flowid, mcb_rcv.opcode);
		if(flowid >= 0)
		{
				//this is my answer
				mcb_reply.opcode = 1;
				mcb_reply.size = 1;
				mcb_reply.data = datareply;
				datareply[0]=100;
				rt_task_reply(flowid, &mcb_reply);
				rt_printf("task2 replied to Sender\n");
		}
		else
		{
			rt_printf("err task2 : flowid neg\n");
		}

		fflush(NULL);
	}
}


void testtask3(void *cookie) {
	RT_TASK_MCB mcb_rcv, mcb_reply;
	int flowid, i, rv;
	unsigned char datareply[16];
	unsigned int taskmsg;

	int count = 0;
	int ret;
	unsigned long overrun;
	ret = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(task_period_ns));
	if (ret) {
		rt_printf("error while set periodic, code %d\n",ret);
		return;
	}

	while(!end){

		ret = rt_task_wait_period(&overrun);
		if (ret) {
			rt_printf("error while rt_task_wait_period, code %d\n",ret);
			return;
		}

		mcb_rcv.data = (caddr_t)&datareply;
		mcb_rcv.size = sizeof(datareply);

		flowid = rt_task_receive(&mcb_rcv,PEER_RATE_NS);
		rt_printf("%s flowid=%d opcode=%d\n",\
				__FUNCTION__, flowid, mcb_rcv.opcode);
		if(flowid >= 0)
		{
				//this is my answer
				mcb_reply.opcode = 1;
				mcb_reply.size = 1;
				mcb_reply.data = datareply;
				datareply[0]=100;
				rt_task_reply(flowid, &mcb_reply);
				rt_printf("task3 replied to Sender\n");
		}
		else
		{
			rt_printf("err task3 : flowid neg\n");
		}

		fflush(NULL);
	}
}


// signal-handler, to ensure clean exit on Ctrl-C
void clean_exit(int dummy) {
	rt_printf("cleanup\n");
	end = 1;
	rt_task_delete(&test_task_ptr);
	rt_printf("end\n");
}

int main(int argc, char *argv[]) {
	int err, ret;
	int itask;


	// install signal handler
	signal(SIGTERM, clean_exit);
	signal(SIGINT, clean_exit);

	mlockall(MCL_CURRENT | MCL_FUTURE);

	/* Perform auto-init of rt_print buffers if the task doesn't do so */
	rt_print_auto_init(1);

	//Initialisation de Dispatch Sender
	for (itask=0; itask < nrecvhost; itask++)
	{
		recvTask[itask]=NULL;
	}

	err = rt_task_spawn(&test_task_ptr, "Timer", STACK_SIZE, STD_PRIO, 0,  
&testtask, NULL);
	recvTask[nrecvhost]=&test_task_ptr;
	nrecvhost++;
	if (err) {
		rt_printf("error rt_task_spawn\n");
		return 0;
	}

	nrecvhost=0;
	rt_printf("Fin Initialisation de la tache Emetteur\n");

	err = rt_task_spawn(&test_task2_ptr, "Timer2", STACK_SIZE, STD_PRIO,  
0, &testtask2, NULL);
	recvTask[nrecvhost]=&test_task2_ptr;
	nrecvhost++;
	if (err) {
		rt_printf("error rt_task_spawn\n");
		return 0;
	}


	err = rt_task_spawn(&test_task3_ptr, "Timer3", STACK_SIZE, STD_PRIO,  
0, &testtask3, NULL);
	recvTask[nrecvhost]=&test_task3_ptr;
	nrecvhost++;
	if (err) {
		rt_printf("error rt_task_spawn\n");
		return 0;
	}



	// wait for signal & return of signal handler
	pause();
	fflush(NULL);
	return 0;
}


Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> a écrit :

> Michel He wrote:
>> hello everyone,
>>
>>     I find out a problem (it seems already mentionned before but I
>> can't find the link to the forum and the post). It deals with the
>> message passing, eg. when we change the order of task execution,
>> something can get wrong. Notice that codes below, if we launch the
>> exection of Recep2,Recep3,Sender, Recep2 won't get the right message.
>> But if we change the order to : Sender,Recep2,Recep3, everything is
>> back to OK. So any explanation ?
>
> A piece of self-contained code, compiling and demonstrating a bug when
> running is worth a thousand words.
>
>
> --
> 					    Gilles.
>




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

end of thread, other threads:[~2010-04-20 15:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-19 17:01 [Xenomai-help] RT_QUEUE problem in Sender/Receiver order Michel He
2010-04-19 17:04 ` Gilles Chanteperdrix
2010-04-20 15:21   ` Michel He
2010-04-19 17:16 ` Philippe Gerum
2010-04-20  4:46   ` Josh Bowman
2010-04-20  8:22     ` Philippe Gerum
2010-04-20 10:20       ` Michel He

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.