[Appendix to the xntimer cleanup series.]

Having to take care for infinite delays in xntimer_start (i.e. to NOT
start the timer...) is a bit suboptimal given that his service might be
used heavily to restart timers. This patch converts the only user
(xnpod_start_timer again) and cleans up the timer code.

Jan
---
 ksrc/nucleus/pod.c   |   10 ++++++----
 ksrc/nucleus/timer.c |   34 ++++++++++++----------------------
 2 files changed, 18 insertions(+), 26 deletions(-)

Index: xenomai/ksrc/nucleus/pod.c
===================================================================
--- xenomai.orig/ksrc/nucleus/pod.c
+++ xenomai/ksrc/nucleus/pod.c
@@ -3095,10 +3095,12 @@ 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);
+	if (delta) {
+		xnlock_get_irqsave(&nklock, s);
+		xntimer_start(&nkpod->htimer, delta,
+			      XNARCH_HOST_TICK / nkpod->tickvalue);
+		xnlock_put_irqrestore(&nklock, s);
+	}
 
 	return 0;
 }
Index: xenomai/ksrc/nucleus/timer.c
===================================================================
--- xenomai.orig/ksrc/nucleus/timer.c
+++ xenomai/ksrc/nucleus/timer.c
@@ -99,20 +99,15 @@ static void xntimer_do_start_aperiodic(x
 	if (!testbits(timer->status, XNTIMER_DEQUEUED))
 		xntimer_dequeue_aperiodic(timer);
 
-	if (value != XN_INFINITE) {
-		xntimerh_date(&timer->aplink) =
-		    xnarch_get_cpu_tsc() + xnarch_ns_to_tsc(value);
-		timer->interval = xnarch_ns_to_tsc(interval);
-		xntimer_enqueue_aperiodic(timer);
-		if (xntimer_heading_p(timer)) {
-			if (xntimer_sched(timer) != xnpod_current_sched())
-				xntimer_next_remote_shot(xntimer_sched(timer));
-			else
-				xntimer_next_local_shot(xntimer_sched(timer));
-		}
-	} else {
-		xntimerh_date(&timer->aplink) = XN_INFINITE;
-		timer->interval = XN_INFINITE;
+	xntimerh_date(&timer->aplink) =
+	    xnarch_get_cpu_tsc() + xnarch_ns_to_tsc(value);
+	timer->interval = xnarch_ns_to_tsc(interval);
+	xntimer_enqueue_aperiodic(timer);
+	if (xntimer_heading_p(timer)) {
+		if (xntimer_sched(timer) != xnpod_current_sched())
+			xntimer_next_remote_shot(xntimer_sched(timer));
+		else
+			xntimer_next_local_shot(xntimer_sched(timer));
 	}
 }
 
@@ -298,14 +293,9 @@ static void xntimer_do_start_periodic(xn
 	if (!testbits(timer->status, XNTIMER_DEQUEUED))
 		xntimer_dequeue_periodic(timer);
 
-	if (value != XN_INFINITE) {
-		xntlholder_date(&timer->plink) = nkpod->jiffies + value;
-		timer->interval = interval;
-		xntimer_enqueue_periodic(timer);
-	} else {
-		xntlholder_date(&timer->plink) = XN_INFINITE;
-		timer->interval = XN_INFINITE;
-	}
+	xntlholder_date(&timer->plink) = nkpod->jiffies + value;
+	timer->interval = interval;
+	xntimer_enqueue_periodic(timer);
 }
 
 static void xntimer_do_stop_periodic(xntimer_t *timer)

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core

Reply via email to