All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] [patch, minor] xnpipe_recv and xntimer_get_timeout_periodic()
@ 2006-08-21  8:36 Dmitry Adamushko
  2006-08-21  9:36 ` Philippe Gerum
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Dmitry Adamushko @ 2006-08-21  8:36 UTC (permalink / raw)
  To: xenomai


[-- Attachment #1.1: Type: text/plain, Size: 1173 bytes --]

[ resent. subject was broken ]

------------------------------------


Hello,

[ pipe.c.patch ]  update the "timeout" variable so that the remaining
timeout is used in case of consequent xnsynch_sleep_on() calls.

As I understand that may indeed happen in case when another thread "steals"
data while this one waits to be scheduled in.

[ timer.c.patch] xnticks_t is unsigned while (as I understand)
"xntlholder_date(&timer->plink) - nkpod->jiffies" can be negative.
In this case, some positive big number is returned and any code that relies
on xnthread_timeout() or xntimer_get_timeout() and runs over periodic mode
won't work properly (e.g. xnsynch_sleep_on() and xnpipe_recv() now). Not
sure 1 should be returned in this case (so far I just did it the same way as
xntimer_get_timeout_aperiodic()), I guess 0 would be better in both cases.

At least in theory, 1 may cause an (even) infinite loop in xnpipe_recv() as
I don't like a check for "timeout > 1" to be placed there. It's something
that should be decided at the timer layer - I mean, whether it's too late to
sleep or not.

hope, I haven't overlooked anything this time :o)


-- 
Best regards,
Dmitry Adamushko

[-- Attachment #1.2: Type: text/html, Size: 1407 bytes --]

[-- Attachment #2: pipe.c.patch --]
[-- Type: text/x-patch, Size: 310 bytes --]

--- pipe-SVN.c	2006-08-20 15:04:25.000000000 +0200
+++ pipe.c	2006-08-20 21:29:55.000000000 +0200
@@ -450,6 +450,9 @@ ssize_t xnpipe_recv(int minor, struct xn
 			ret = -EIDRM;
 			goto unlock_and_exit;
 		}
+
+		/* remaining timeout */		
+		timeout = xnthread_timeout(thread);
 	}
 
 	*pmh = link2mh(holder);

[-- Attachment #3: timer.c.patch --]
[-- Type: text/x-patch, Size: 534 bytes --]

--- timer-SVN.c	2006-08-20 15:50:18.000000000 +0200
+++ timer.c	2006-08-20 15:54:30.000000000 +0200
@@ -313,7 +313,12 @@ static xnticks_t xntimer_get_date_period
 
 static xnticks_t xntimer_get_timeout_periodic(xntimer_t *timer)
 {
-	return xntlholder_date(&timer->plink) - nkpod->jiffies;
+	xnticks_t now = nkpod->jiffies;
+	
+	if (xntlholder_date(&timer->plink) < now)
+		return 1;	/* Will elapse shortly. */
+	
+	return xntlholder_date(&timer->plink) - now;
 }
 
 static xnticks_t xntimer_get_raw_expiry_periodic(xntimer_t *timer)

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

end of thread, other threads:[~2006-08-21 18:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-21  8:36 [Xenomai-core] [patch, minor] xnpipe_recv and xntimer_get_timeout_periodic() Dmitry Adamushko
2006-08-21  9:36 ` Philippe Gerum
2006-08-21  9:49 ` Philippe Gerum
2006-08-21 17:45   ` Dmitry Adamushko
2006-08-21 18:02     ` Philippe Gerum
2006-08-21 10:02 ` Philippe Gerum
2006-08-21 10:47   ` Dmitry Adamushko
2006-08-21 11:27     ` Philippe Gerum
     [not found]       ` <b647ffbd0608210446v38656cecxc231dba4e8f55dc2@domain.hid>
2006-08-21 11:47         ` Dmitry Adamushko
2006-08-21 12:45           ` Philippe Gerum

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.