Module: xenomai-forge
Branch: next
Commit: e2c2c64057789c1f383bc7c664b48e5cdfea227d
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=e2c2c64057789c1f383bc7c664b48e5cdfea227d

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Jul  2 19:03:08 2014 +0200

alchemy/task: fix rt_task_set_periodic()

---

 lib/alchemy/task.c |   21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c
index 8de9257..26e29cb 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -826,15 +826,30 @@ undo:
  */
 int rt_task_set_periodic(RT_TASK *task, RTIME idate, RTIME period)
 {
-       struct timespec its, pts;
+       struct timespec its, pts, now;
        struct alchemy_task *tcb;
        struct service svc;
        int ret;
 
        CANCEL_DEFER(svc);
 
-       clockobj_ticks_to_timespec(&alchemy_clock, idate, &its);
-       clockobj_ticks_to_timespec(&alchemy_clock, period, &pts);
+       if (period == TM_INFINITE) {
+               pts.tv_sec = 0;
+               pts.tv_nsec = 0;
+               its = pts;
+       } else {
+               clockobj_ticks_to_timespec(&alchemy_clock, period, &pts);
+               if (idate == TM_NOW) {
+                       __RT(clock_gettime(CLOCK_COPPERPLATE, &now));
+                       timespec_add(&its, &now, &pts);
+               } else
+                       /*
+                        * idate is an absolute time specification
+                        * already, so we want a direct conversion to
+                        * timespec.
+                        */
+                       clockobj_ticks_to_timespec(&alchemy_clock, idate, &its);
+       }
 
        tcb = get_alchemy_task_or_self(task, &ret);
        if (tcb == NULL)


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to