Message-ID: <20061027151347.62705.qmail@domain.hid> Date: Fri, 27 Oct 2006 08:13:47 -0700 (PDT) From: mani bhatti Subject: Re: [Xenomai-help] Problem with rt_queue In-Reply-To: <453FEA27.3020705@domain.hid> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1455400731-1161962027=:62103" Content-Transfer-Encoding: 8bit List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: xenomai@xenomai.org --0-1455400731-1161962027=:62103 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Thanks a lot Jan for the reply.Now after changing the task name queue is working but following message is displayed by the sender if there is no queue which you had pointed in the last email. rt_queue_alloc(queue_inout, 8) failed Segmentation fault Actually i dont understand about the patch which you had sent in your last email (because patch seems to be incomple to me ) because that seems to be part of xenomai source code and if that is how can i use that source code in my program for solving my problem i mean at which place in my program should i put that patch .Sorry for your inconvenience.thanks. Jan Kiszka wrote: mani bhatti wrote: > Hi Phillipe and Jan > Thanks a lot for your help.I am sending the compilable > source code so that you have an idea what wrong am i > doing.I am sending the listeners which are listening > to the same queue at the same time.But i dont know why > at one time only one listener receives data from > sender queue inspite of that i am using broadcast > mode.Thanks a lot.I have attached files for sender and > listener. Well, interesting test case. It actually revealed bugs, but not where expected. Your problem is a simple bug in the listener tests. They both register a task of the name "beta", only the first one succeeds (your code is a bit hackish in this regard - when hunting problems, make sure to check ALL return codes for potential problems!). Once fixed, your code runs fine here. Nevertheless, queue_sender by itself uncovered a problem of rt_queue_send in broadcast mode when no one is listening. The message reference count got messed up and the queue ran out of memory. The attached patch fixes it: Jan Index: ksrc/skins/native/queue.c =================================================================== --- ksrc/skins/native/queue.c (Revision 1747) +++ ksrc/skins/native/queue.c (Arbeitskopie) @@ -631,7 +631,9 @@ int rt_queue_send(RT_QUEUE *q, void *mbu prependq(&q->pendq, &msg->link); else appendq(&q->pendq, &msg->link); - } + } else + /* Ownership did not change, so update reference count. */ + msg->refcount++; err = nrecv; Index: ChangeLog =================================================================== --- ChangeLog (Revision 1748) +++ ChangeLog (Arbeitskopie) @@ -1,3 +1,8 @@ +2006-10-26 Jan Kiszka + + * ksrc/skins/native/queue.c (rt_queue_send): Track message count + correctly when broadcasting to a queue without listeners. + 2006-10-25 Jan Kiszka * ksrc/drivers/testing/irqbench.c, doc/txt/irqbench.txt, --------------------------------- All-new Yahoo! Mail - Fire up a more powerful email and get things done faster. --0-1455400731-1161962027=:62103 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit
Thanks a lot Jan for the reply.Now after changing the task name queue is working but
following message is displayed by the sender if there is no queue which you had pointed in the last email.
rt_queue_alloc(queue_inout, 8) failed
Segmentation fault
Actually i dont  understand about the patch which you had sent in your last email (because patch seems to be incomple to me ) because that seems to be part of xenomai source code and if that is how can i use that source code in my program for solving my problem i mean at which place in my program should i put that patch .Sorry for your inconvenience.thanks.

 


Jan Kiszka <jan.kiszka@domain.hid> wrote:
mani bhatti wrote:
> Hi Phillipe and Jan
> Thanks a lot for your help.I am sending the compilable
> source code so that you have an idea what wrong am i
> doing.I am sending the listeners which are listening
> to the same queue at the same time.But i dont know why
> at one time only one listener receives data from
> sender queue inspite of that i am using broadcast
> mode.Thanks a lot.I have attached files for sender and
> listener.

Well, interesting test case. It actually revealed bugs, but not where
expected.

Your problem is a simple bug in the listener tests. They both register a
task of the name "beta", only the first one succeeds (your code is a bit
hackish in this regard - when hunting problems, make sure to check ALL
return codes for potential problems!). Once fixed, your code runs fine here.

Nevertheless, queue_sender by itself uncovered a problem of
rt_queue_send in broadcast mode when no one is listening. The message
reference count got messed up and the queue ran out of memory. The
attached patch fixes it:

Jan
Index: ksrc/skins/native/queue.c
===================================================================
--- ksrc/skins/native/queue.c (Revision 1747)
+++ ksrc/skins/native/queue.c (Arbeitskopie)
@@ -631,7 +631,9 @@ int rt_queue_send(RT_QUEUE *q, void *mbu
prependq(&q->pendq, &msg->link);
else
appendq(&q->pendq, &msg->link);
- }
+ } else
+ /* Ownership did not change, so update reference count. */
+ msg->refcount++;

err = nrecv;

Index: ChangeLog
===================================================================
--- ChangeLog (Revision 1748)
+++ ChangeLog (Arbeitskopie)
@@ -1,3 +1,8 @@
+2006-10-26 Jan Kiszka
+
+ * ksrc/skins/native/queue.c (rt_queue_send): Track message count
+ correctly when broadcasting to a queue without listeners.
+
2006-10-25 Jan Kiszka

* ksrc/drivers/testing/irqbench.c, doc/txt/irqbench.txt,


All-new Yahoo! Mail - Fire up a more powerful email and get things done faster. --0-1455400731-1161962027=:62103--