All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Thierry Bultel <thierry.bultel@basystemes.fr>, xenomai@xenomai.org
Cc: Céline <celine.leberre.prestataire@basystemes.fr>
Subject: Re: [Xenomai] Are concurrent writes to XDDP sockets allowed ?
Date: Fri, 22 May 2015 09:42:14 +0200	[thread overview]
Message-ID: <555EDDD6.9010305@xenomai.org> (raw)
In-Reply-To: <555DFAA7.3090001@basystemes.fr>

On 05/21/2015 05:32 PM, Thierry Bultel wrote:
> 
> 
> Le 21/05/2015 17:23, Philippe Gerum a écrit :
>> On 05/21/2015 05:03 PM, Thierry Bultel wrote:
>>>
>>> Le 21/05/2015 14:07, Philippe Gerum a écrit :
>>>> On 05/21/2015 08:34 AM, Thierry Bultel wrote:
>>>>> Hi,
>>>>> In an application, we have one regular thread listening on an RTP
>>>>> device,
>>>>> and 2 realtime threads that concurrently write data in the XDDP socket
>>>>> backend.
>>>>> We use the POSIX skin.
>>>>>
>>>>> Sometimes, the regular thread gets its blocking read() call just
>>>>> return 0.
>>>>> That never happens with the classic "one reader, one writer" case.
>>>>>
>>>>> Also, we notice that the 'return 0' case occurrence is not the same,
>>>>> depending
>>>>> on the fact that the realtime task uses 'write' instead of 'sendto'
>>>>> (more occurrences with 'sendto')
>>>>>
>>>> There is no restriction with respect to concurrent sending to such
>>>> socket.
>>> Ok, thanks
>>>> Knowing about the Xenomai release number,
>>> This is 2.6.4
>>>> and a simple test code that
>>>> actually illustrates the intended usage and ideally reproduces the
>>>> issue
>>>> would help.
>>> Here is the test code, based on xddp-echo.c . Unfortunalely this does
>>> not reproduce the issue.
>>> Compared to our application, we also have 3 other additional
>>> realtime-regular pairs communicating on 3 dedicated channels.
>>>
>>> What would trigger the 'read' return with zero ?
>> Sending zero len messages from the rt side via sendto(), which is legit
>> with XDDP. Using write() won't send anything.
>>
> This was my first assumption.
> But the way we use it eliminates that possible cause; the sent struct is
> on stack.
> Moreover, we have 'zero' read even when using the 'write' instead of
> 'sendto'
> 'sendto' just seem to increase the number of zero read occurences.
> 
>    RAWFRAME message;
> 
> ...
> 
>         nb = write(channel, &message, sizeof(message));
> 
> 
> 

Any spurious wake up fixed with this?

diff --git a/ksrc/nucleus/pipe.c b/ksrc/nucleus/pipe.c
index 3c4dccf..df587ab 100644
--- a/ksrc/nucleus/pipe.c
+++ b/ksrc/nucleus/pipe.c
@@ -122,13 +122,17 @@ static inline void xnpipe_dequeue_all(struct xnpipe_state *state, int mask)
 	xnpipe_enqueue_wait(__state, __mask);				\
 	xnlock_put_irqrestore(&nklock, __s);				\
 									\
-	prepare_to_wait_exclusive(__waitq, &__wait, TASK_INTERRUPTIBLE);\
-									\
-	if (!(__cond))							\
+	for (;;) {							\
+		__sigpending = signal_pending(current);			\
+		if (__sigpending)					\
+			break;						\
+		prepare_to_wait_exclusive(__waitq, &__wait, TASK_INTERRUPTIBLE); \
+		if (__cond)						\
+			break;						\
 		schedule();						\
+	}								\
 									\
 	finish_wait(__waitq, &__wait);					\
-	__sigpending = signal_pending(current);				\
 									\
 	/* Restore the interrupt state initially set by the caller. */	\
 	xnlock_get_irqsave(&nklock, __s);

-- 
Philippe.


  reply	other threads:[~2015-05-22  7:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <555D77F6.7030007@basystemes.fr>
2015-05-21  6:34 ` [Xenomai] Are concurrent writes to XDDP sockets allowed ? Thierry Bultel
2015-05-21 12:07   ` Philippe Gerum
2015-05-21 15:03     ` Thierry Bultel
2015-05-21 15:23       ` Philippe Gerum
2015-05-21 15:32         ` Thierry Bultel
2015-05-22  7:42           ` Philippe Gerum [this message]
2015-05-22 10:26             ` Thierry Bultel

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=555EDDD6.9010305@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=celine.leberre.prestataire@basystemes.fr \
    --cc=thierry.bultel@basystemes.fr \
    --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.