All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] [RFC][PATCH 4/4] shorten overrun loops of periodic timers
@ 2006-08-03  7:01 Jan Kiszka
  2006-08-03 17:01 ` Philippe Gerum
  2006-08-03 17:26 ` Gilles Chanteperdrix
  0 siblings, 2 replies; 11+ messages in thread
From: Jan Kiszka @ 2006-08-03  7:01 UTC (permalink / raw)
  To: xenomai-core


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

A simple patch, just like suggested by Gilles, to avoid looping over
periodic xntimer handlers in case of overruns.

It saves the current TSC on loop entry and uses this value later when
forwarding the timer. Is is the overhead of re-reading the TSC on all
archs negligible and should we rather go that way?

Jan

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: xntimer-handle-periodic-overrun.patch --]
[-- Type: text/x-patch; name="xntimer-handle-periodic-overrun.patch", Size: 1209 bytes --]

---
 ksrc/nucleus/timer.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Index: xenomai/ksrc/nucleus/timer.c
===================================================================
--- xenomai.orig/ksrc/nucleus/timer.c
+++ xenomai/ksrc/nucleus/timer.c
@@ -200,12 +200,13 @@ static void xntimer_do_tick_aperiodic(vo
 	xntimerq_t *timerq = &sched->timerqueue;
 	xntimerh_t *holder;
 	xntimer_t *timer;
+	xnticks_t now;
 
 	while ((holder = xntimerq_head(timerq)) != NULL) {
 		timer = aplink2timer(holder);
 
-		if (xntimerh_date(&timer->aplink) - nkschedlat >
-		    xnarch_get_cpu_tsc())
+		now = xnarch_get_cpu_tsc();
+		if (xntimerh_date(&timer->aplink) - nkschedlat > now)
 			/* No need to continue in aperiodic mode since timeout
 			   dates are ordered by increasing values. */
 			break;
@@ -236,8 +237,8 @@ static void xntimer_do_tick_aperiodic(vo
 				}
 #endif /* CONFIG_XENO_OPT_DEBUG || __XENO_SIM__ */
 			} else if (timer->interval == XN_INFINITE) {
-				xntimerh_date(&timer->aplink) +=
-				    nkpod->htimer.interval;
+				while ((xntimerh_date(&timer->aplink) +=
+				        nkpod->htimer.interval) < now);
 				continue;
 			}
 		} else

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

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

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

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-03  7:01 [Xenomai-core] [RFC][PATCH 4/4] shorten overrun loops of periodic timers Jan Kiszka
2006-08-03 17:01 ` Philippe Gerum
2006-08-03 17:26 ` Gilles Chanteperdrix
2006-08-03 18:37   ` Jan Kiszka
2006-08-16 15:43     ` Gilles Chanteperdrix
2006-08-16 16:20       ` Jan Kiszka
2006-08-16 17:22         ` Gilles Chanteperdrix
2006-08-17  7:55           ` Jan Kiszka
2006-08-17 13:03             ` Gilles Chanteperdrix
2006-08-17 13:35               ` Jan Kiszka
2006-08-18  6:09                 ` Jan Kiszka

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.