Round up in RTDM converting ns to ticks
PATCH 2/2 Round up in RTDM converting ns to ticks
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
--- include/rtdm/rtdm_driver.h | 11 +++++------ ksrc/skins/rtdm/drvlib.c | 32 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 22 deletions(-)
include/rtdm/rtdm_driver.h +5 -6
@@ -876,8 +876,8 @@ static inline int rtdm_timer_start_in_hananosecs_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)
ksrc/skins/rtdm/drvlib.c +16 -16
@@ -145,8 +145,8 @@ int rtdm_task_init(rtdm_task_t *task, coif (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 *timerint 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,
Philippe Gerum
AppliedQuoted 3 lines · Jan Kiszka
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).
Merged, thanks.
Quoted 5 lines
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.
One reason more for people to test -rc releases.
Quoted 125 lines
Jan
plain text document attachment (round-up-in-rtdm.patch)--- 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
===================================================================include/rtdm/rtdm_driver.h +5
-6@@ -876,8 +876,8 @@ static inline int rtdm_timer_start_in_hananosecs_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
===================================================================ksrc/skins/rtdm/drvlib.c +16
-16@@ -145,8 +145,8 @@ int rtdm_task_init(rtdm_task_t *task, coif (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 *timerint 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,_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core
Signature · 1 line
Philippe.