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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sun Sep  8 18:51:17 2013 +0200

cobalt/shadow: allow for a minimum wait time in xnshadow_yield()

---

 include/cobalt/kernel/shadow.h |    2 +-
 kernel/cobalt/posix/thread.c   |    2 +-
 kernel/cobalt/shadow.c         |   15 +++++++++++----
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/include/cobalt/kernel/shadow.h b/include/cobalt/kernel/shadow.h
index 71205e7..4fdc221 100644
--- a/include/cobalt/kernel/shadow.h
+++ b/include/cobalt/kernel/shadow.h
@@ -123,7 +123,7 @@ xnshadow_push_personality(struct xnthread *thread,
 void xnshadow_pop_personality(struct xnthread *thread,
                              struct xnpersonality *prev);
 
-int xnshadow_yield(xnticks_t timeout);
+int xnshadow_yield(xnticks_t min, xnticks_t max);
 
 extern struct xnpersonality xenomai_personality;
 
diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index 92612b7..55216e1 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -1257,7 +1257,7 @@ int cobalt_sched_yield(void)
         * arbitrary TICK_NSEC value to limit the wait time to a
         * reasonable amount.
         */
-       return xnshadow_yield(TICK_NSEC);
+       return xnshadow_yield(TICK_NSEC, TICK_NSEC);
 }
 
 #ifdef CONFIG_XENO_OPT_SCHED_TP
diff --git a/kernel/cobalt/shadow.c b/kernel/cobalt/shadow.c
index c8d5d5f..8a9ac9c 100644
--- a/kernel/cobalt/shadow.c
+++ b/kernel/cobalt/shadow.c
@@ -2279,13 +2279,20 @@ static int handle_taskexit_event(struct task_struct *p) 
/* p == current */
        return EVENT_PROPAGATE;
 }
 
-int xnshadow_yield(xnticks_t timeout)
+int xnshadow_yield(xnticks_t min, xnticks_t max)
 {
+       xnticks_t start;
        int ret;
 
-       ret = xnsynch_sleep_on(&yield_sync, timeout, XN_RELATIVE);
-       if (ret & XNBREAK)
-               return -EINTR;
+       start = xnclock_read_monotonic(&nkclock);
+       max += start;
+       min += start;
+
+       do {
+               ret = xnsynch_sleep_on(&yield_sync, max, XN_ABSOLUTE);
+               if (ret & XNBREAK)
+                       return -EINTR;
+       } while (ret == 0 && xnclock_read_monotonic(&nkclock) < min);
 
        return 0;
 }


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

Reply via email to