All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] [RFC][PATCH] nucleus: Prevent rescheduling while in xntbase_tick
@ 2011-06-17  9:27 Jan Kiszka
  2011-06-17 10:58 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kiszka @ 2011-06-17  9:27 UTC (permalink / raw)
  To: Xenomai core

Based on code inspection, it looks like a timer handler triggering a
reschedule in the path xntbase_tick -> xntimer_tick_aperiodic /
xntimer_tick_periodic_inner -> handler can cause problems, e.g. a
reschedule before all expired timers were processed. The timer core is
usually run atomically from an interrupt handler, so better emulate an
IRQ context inside xntbase_tick by setting XNINIRQ.

This patch only affects users of xntbase_tick, ie. psos, vrtx and the
vxworks skin.

Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
---

If my analysis is correct, this is also 2.5 material.

 ksrc/nucleus/timebase.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/ksrc/nucleus/timebase.c b/ksrc/nucleus/timebase.c
index 6f7c02f..8f9af04 100644
--- a/ksrc/nucleus/timebase.c
+++ b/ksrc/nucleus/timebase.c
@@ -477,12 +477,16 @@ EXPORT_SYMBOL_GPL(xntbase_stop);
 
 void xntbase_tick(xntbase_t *base)
 {
+	struct xnsched_t *sched;
 	spl_t s;
 
 	xnlock_get_irqsave(&nklock, s);
 
 	trace_mark(xn_nucleus, tbase_tick, "base %s", base->name);
 
+	++sched->inesting;
+	__setbits(sched->lflags, XNINIRQ);
+
 	if (base == &nktbase)
 		xntimer_tick_aperiodic();
 	else {
@@ -490,6 +494,11 @@ void xntbase_tick(xntbase_t *base)
 		xntimer_tick_periodic_inner(slave);
 	}
 
+	if (--sched->inesting == 0) {
+		__clrbits(sched->lflags, XNINIRQ);
+		xnpod_schedule();
+	}
+
 	xnlock_put_irqrestore(&nklock, s);
 }
 EXPORT_SYMBOL_GPL(xntbase_tick);
-- 
1.7.1


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

end of thread, other threads:[~2011-06-17 12:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-17  9:27 [Xenomai-core] [RFC][PATCH] nucleus: Prevent rescheduling while in xntbase_tick Jan Kiszka
2011-06-17 10:58 ` Gilles Chanteperdrix
2011-06-17 11:03   ` Jan Kiszka
2011-06-17 11:58     ` Philippe Gerum
2011-06-17 12:11       ` Jan Kiszka
2011-06-17 12:12         ` 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.