All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: xenomai-core <xenomai@xenomai.org>
Cc: "Markus Osterried (BA/EDD)" <markus.osterried@domain.hid>
Subject: [Xenomai-core] [PATCH 2/2] Round up in RTDM converting ns to ticks
Date: Thu, 30 Aug 2007 09:11:35 +0200	[thread overview]
Message-ID: <46D66DA7.6060800@domain.hid> (raw)


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

As suggested by Markus, this patch lets RTDM round up when nanoseconds
are to be converted to ticks (only relevant if RTDM runs over a
periodic, tick-based timebase).

This is against trunk only, I haven't yet decided what to do with 2.3.x.
The rounding change may have unexpected side-effects, so I'm hesitating
to change the stable version as well.

Jan

[-- Attachment #1.2: round-up-in-rtdm.patch --]
[-- Type: text/plain, Size: 4086 bytes --]

---
 include/rtdm/rtdm_driver.h |   11 +++++------
 ksrc/skins/rtdm/drvlib.c   |   32 ++++++++++++++++----------------
 2 files changed, 21 insertions(+), 22 deletions(-)

Index: xenomai/include/rtdm/rtdm_driver.h
===================================================================
--- xenomai.orig/include/rtdm/rtdm_driver.h
+++ xenomai/include/rtdm/rtdm_driver.h
@@ -876,8 +876,8 @@ static inline int rtdm_timer_start_in_ha
 					      nanosecs_rel_t interval,
 					      enum rtdm_timer_mode mode)
 {
-	return xntimer_start(timer, xntbase_ns2ticks(rtdm_tbase, expiry),
-			     xntbase_ns2ticks(rtdm_tbase, interval),
+	return xntimer_start(timer, xntbase_ns2ticks_ceil(rtdm_tbase, expiry),
+			     xntbase_ns2ticks_ceil(rtdm_tbase, interval),
 			     (xntmode_t)mode);
 }
 
@@ -945,10 +945,9 @@ static inline int rtdm_task_set_period(r
 {
 	if (period < 0)
 		period = 0;
-	return
-	    xnpod_set_thread_periodic(task, XN_INFINITE,
-				      xntbase_ns2ticks(xnthread_time_base(task),
-						       period));
+	return xnpod_set_thread_periodic(task, XN_INFINITE,
+					 xntbase_ns2ticks_ceil
+					 (xnthread_time_base(task), period));
 }
 
 static inline int rtdm_task_unblock(rtdm_task_t *task)
Index: xenomai/ksrc/skins/rtdm/drvlib.c
===================================================================
--- xenomai.orig/ksrc/skins/rtdm/drvlib.c
+++ xenomai/ksrc/skins/rtdm/drvlib.c
@@ -145,8 +145,8 @@ int rtdm_task_init(rtdm_task_t *task, co
 
 	if (period > 0) {
 		res = xnpod_set_thread_periodic(task, XN_INFINITE,
-						xntbase_ns2ticks(rtdm_tbase,
-								 period));
+						xntbase_ns2ticks_ceil
+						(rtdm_tbase,  period));
 		if (res)
 			goto cleanup_out;
 	}
@@ -370,8 +370,8 @@ int __rtdm_task_sleep(xnticks_t timeout,
 	XENO_ASSERT(RTDM, !xnpod_unblockable_p(), return -EPERM;);
 
 	xnpod_suspend_thread(thread, XNDELAY,
-			     xntbase_ns2ticks(xnthread_time_base(thread),
-					      timeout), mode, NULL);
+			     xntbase_ns2ticks_ceil(xnthread_time_base(thread),
+						   timeout), mode, NULL);
 
 	return xnthread_test_info(thread, XNBREAK) ? -EINTR : 0;
 }
@@ -544,8 +544,8 @@ int rtdm_timer_start(rtdm_timer_t *timer
 	int err;
 
 	xnlock_get_irqsave(&nklock, s);
-	err = xntimer_start(timer, xntbase_ns2ticks(rtdm_tbase, expiry),
-			    xntbase_ns2ticks(rtdm_tbase, interval),
+	err = xntimer_start(timer, xntbase_ns2ticks_ceil(rtdm_tbase, expiry),
+			    xntbase_ns2ticks_ceil(rtdm_tbase, interval),
 			    (xntmode_t)mode);
 	xnlock_put_irqrestore(&nklock, s);
 
@@ -714,7 +714,7 @@ void rtdm_toseq_init(rtdm_toseq_t *timeo
 	XENO_ASSERT(RTDM, !xnpod_unblockable_p(), /* only warn here */;);
 
 	*timeout_seq =
-	    xntbase_get_jiffies(base) + xntbase_ns2ticks(base, timeout);
+	    xntbase_get_jiffies(base) + xntbase_ns2ticks_ceil(base, timeout);
 }
 
 EXPORT_SYMBOL(rtdm_toseq_init);
@@ -934,9 +934,9 @@ int rtdm_event_timedwait(rtdm_event_t *e
 		} else {
 			/* infinite or relative timeout */
 			xnsynch_sleep_on(&event->synch_base,
-				xntbase_ns2ticks(xnthread_time_base(thread),
-						 timeout),
-				XN_RELATIVE);
+					 xntbase_ns2ticks_ceil
+					 (xnthread_time_base(thread), timeout),
+					 XN_RELATIVE);
 		}
 
 		if (likely
@@ -1143,9 +1143,9 @@ int rtdm_sem_timeddown(rtdm_sem_t *sem, 
 		} else {
 			/* infinite or relative timeout */
 			xnsynch_sleep_on(&sem->synch_base,
-				xntbase_ns2ticks(xnthread_time_base(thread),
-						 timeout),
-				XN_RELATIVE);
+					 xntbase_ns2ticks_ceil
+					 (xnthread_time_base(thread), timeout),
+					 XN_RELATIVE);
 		}
 
 		if (xnthread_test_info(thread, XNTIMEO | XNRMID | XNBREAK)) {
@@ -1377,9 +1377,9 @@ restart:
 		} else {
 			/* infinite or relative timeout */
 			xnsynch_sleep_on(&mutex->synch_base,
-				xntbase_ns2ticks(xnthread_time_base(curr_thread),
-						 timeout),
-				XN_RELATIVE);
+					 xntbase_ns2ticks_ceil
+					 (xnthread_time_base(curr_thread),
+					  timeout), XN_RELATIVE);
 		}
 
 		if (unlikely(xnthread_test_info(curr_thread,

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

             reply	other threads:[~2007-08-30  7:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-30  7:11 Jan Kiszka [this message]
2007-09-07  7:23 ` [Xenomai-core] [PATCH 2/2] Round up in RTDM converting ns to ticks Philippe Gerum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46D66DA7.6060800@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=markus.osterried@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.