* [Xenomai-core] [PATCH 2/2] simplify xntimer_start
@ 2006-07-18 23:48 Jan Kiszka
2006-07-19 8:28 ` Philippe Gerum
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2006-07-18 23:48 UTC (permalink / raw)
To: xenomai-core
[-- Attachment #1.1: Type: text/plain, Size: 315 bytes --]
Almost all callers of xntimer_start already run in nklock-protected
context. Therefore, we can save the lock reacquisition in that function
and turn it even into a trivial inliner. This patch also takes care of
the two exceptions of the rule above in xnpod_start_timer and psos+'s
tm_start_event_timer.
Jan
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: xntimer-start-no-lock.patch --]
[-- Type: text/x-patch; name="xntimer-start-no-lock.patch", Size: 5864 bytes --]
---
include/nucleus/timer.h | 51 +++++++++++++++++++++++++++++++++++++++++++++---
ksrc/nucleus/pod.c | 2 +
ksrc/nucleus/timer.c | 49 ----------------------------------------------
ksrc/skins/psos+/tm.c | 4 ++-
4 files changed, 53 insertions(+), 53 deletions(-)
Index: include/nucleus/timer.h
===================================================================
--- include/nucleus/timer.h.orig
+++ include/nucleus/timer.h
@@ -290,9 +290,52 @@ void xntimer_init(xntimer_t *timer,
void xntimer_destroy(xntimer_t *timer);
-void xntimer_start(xntimer_t *timer,
- xnticks_t value,
- xnticks_t interval);
+/*!
+ * \fn void xntimer_start(xntimer_t *timer,xnticks_t value,xnticks_t interval)
+ * \brief Arm a timer.
+ *
+ * Activates a timer so that the associated timeout handler will be
+ * fired after each expiration time. A timer can be either periodic or
+ * single-shot, depending on the reload value passed to this
+ * routine. The given timer must have been previously initialized by a
+ * call to xntimer_init().
+ *
+ * @param timer The address of a valid timer descriptor.
+ *
+ * @param value The relative date of the initial timer shot, expressed
+ * in clock ticks (see note).
+ *
+ * @param interval The reload value of the timer. It is a periodic
+ * interval value to be used for reprogramming the next timer shot,
+ * expressed in clock ticks (see note). If @a interval is equal to
+ * XN_INFINITE, the timer will not be reloaded after it has expired.
+ *
+ * @return 0 is always returned.
+ *
+ * Environments:
+ *
+ * This service can be called from:
+ *
+ * - Kernel module initialization/cleanup code
+ * - Interrupt service routine
+ * - Kernel-based task
+ * - User-space task
+ *
+ * Rescheduling: never.
+ *
+ * @note This service is sensitive to the current operation mode of
+ * the system timer, as defined by the xnpod_start_timer() service. In
+ * periodic mode, clock ticks are interpreted as periodic jiffies. In
+ * oneshot mode, clock ticks are interpreted as nanoseconds.
+ *
+ * @note Must be called with nklock held, IRQs off.
+ */
+
+static inline void xntimer_start(xntimer_t *timer,
+ xnticks_t value, xnticks_t interval)
+{
+ nktimer->do_timer_start(timer, value, interval);
+}
/*!
* \fn int xntimer_stop(xntimer_t *timer)
@@ -315,6 +358,8 @@ void xntimer_start(xntimer_t *timer,
* - User-space task
*
* Rescheduling: never.
+ *
+ * @note Must be called with nklock held, IRQs off.
*/
static inline void xntimer_stop(xntimer_t *timer)
Index: ksrc/nucleus/pod.c
===================================================================
--- ksrc/nucleus/pod.c.orig
+++ ksrc/nucleus/pod.c
@@ -3095,8 +3095,10 @@ int xnpod_start_timer(u_long nstick, xni
xntimer_set_sched(&nkpod->htimer, xnpod_sched_slot(XNTIMER_KEEPER_ID));
+ xnlock_get_irqsave(&nklock, s);
xntimer_start(&nkpod->htimer, delta,
XNARCH_HOST_TICK / nkpod->tickvalue);
+ xnlock_put_irqrestore(&nklock, s);
return 0;
}
Index: ksrc/nucleus/timer.c
===================================================================
--- ksrc/nucleus/timer.c.orig
+++ ksrc/nucleus/timer.c
@@ -539,54 +539,6 @@ void xntimer_destroy(xntimer_t *timer)
timer->sched = NULL;
}
-/*!
- * \fn void xntimer_start(xntimer_t *timer,xnticks_t value,xnticks_t interval)
- * \brief Arm a timer.
- *
- * Activates a timer so that the associated timeout handler will be
- * fired after each expiration time. A timer can be either periodic or
- * single-shot, depending on the reload value passed to this
- * routine. The given timer must have been previously initialized by a
- * call to xntimer_init().
- *
- * @param timer The address of a valid timer descriptor.
- *
- * @param value The relative date of the initial timer shot, expressed
- * in clock ticks (see note).
- *
- * @param interval The reload value of the timer. It is a periodic
- * interval value to be used for reprogramming the next timer shot,
- * expressed in clock ticks (see note). If @a interval is equal to
- * XN_INFINITE, the timer will not be reloaded after it has expired.
- *
- * @return 0 is always returned.
- *
- * Environments:
- *
- * This service can be called from:
- *
- * - Kernel module initialization/cleanup code
- * - Interrupt service routine
- * - Kernel-based task
- * - User-space task
- *
- * Rescheduling: never.
- *
- * @note This service is sensitive to the current operation mode of
- * the system timer, as defined by the xnpod_start_timer() service. In
- * periodic mode, clock ticks are interpreted as periodic jiffies. In
- * oneshot mode, clock ticks are interpreted as nanoseconds.
- */
-
-void xntimer_start(xntimer_t *timer, xnticks_t value, xnticks_t interval)
-{
- spl_t s;
-
- xnlock_get_irqsave(&nklock, s);
- nktimer->do_timer_start(timer, value, interval);
- xnlock_put_irqrestore(&nklock, s);
-}
-
#if defined(CONFIG_SMP)
/**
* Migrate a timer.
@@ -776,7 +728,6 @@ xntmops_t *nktimer = &timer_ops_aperiodi
EXPORT_SYMBOL(xntimer_init);
EXPORT_SYMBOL(xntimer_destroy);
-EXPORT_SYMBOL(xntimer_start);
#if defined(CONFIG_SMP)
EXPORT_SYMBOL(xntimer_set_sched);
#endif /* CONFIG_SMP */
Index: ksrc/skins/psos+/tm.c
===================================================================
--- ksrc/skins/psos+/tm.c.orig
+++ ksrc/skins/psos+/tm.c
@@ -87,12 +87,14 @@ static u_long tm_start_event_timer(u_lon
tm->magic = PSOS_TM_MAGIC;
xnlock_get_irqsave(&nklock, s);
+
appendq(&psostimerq, &tm->link);
appendgq(&tm->owner->alarmq, tm);
- xnlock_put_irqrestore(&nklock, s);
xntimer_start(&tm->timerbase, ticks, interval);
+ xnlock_put_irqrestore(&nklock, s);
+
return SUCCESS;
}
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Xenomai-core] [PATCH 2/2] simplify xntimer_start
2006-07-18 23:48 [Xenomai-core] [PATCH 2/2] simplify xntimer_start Jan Kiszka
@ 2006-07-19 8:28 ` Philippe Gerum
0 siblings, 0 replies; 2+ messages in thread
From: Philippe Gerum @ 2006-07-19 8:28 UTC (permalink / raw)
To: Jan Kiszka; +Cc: xenomai-core
On Wed, 2006-07-19 at 01:48 +0200, Jan Kiszka wrote:
> Almost all callers of xntimer_start already run in nklock-protected
> context. Therefore, we can save the lock reacquisition in that function
> and turn it even into a trivial inliner. This patch also takes care of
> the two exceptions of the rule above in xnpod_start_timer and psos+'s
> tm_start_event_timer.
Applied, thanks.
>
> Jan
> _______________________________________________
> Xenomai-core mailing list
> Xenomai-core@domain.hid
> https://mail.gna.org/listinfo/xenomai-core
--
Philippe.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-07-19 8:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-18 23:48 [Xenomai-core] [PATCH 2/2] simplify xntimer_start Jan Kiszka
2006-07-19 8:28 ` 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.