[Xenomai-git] Philippe Gerum : lib/cobalt: make relaxed threads [sched_]yield() to the regular kernel

2013-10-01 Thread git repository hosting
Module: xenomai-forge
Branch: master
Commit: 545d134bc17443651e3c94c673eba1f471cf
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=545d134bc17443651e3c94c673eba1f471cf

Author: Philippe Gerum r...@xenomai.org
Date:   Sat Aug 31 11:04:44 2013 +0200

lib/cobalt: make relaxed threads [sched_]yield() to the regular kernel

Calling sched_yield() from a relaxed context should yield control to
the regular kernel. There is no point in switching back to primary
mode for running Xenomai's yield service, which is most likely to
force a migration through the secondary mode yet again.

When the user code runs a tight loop yielding the CPU continuously
over a non-rt thread (i.e. WEAK scheduling), the overhead is
significantly lower.

---

 lib/cobalt/thread.c |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index 15a665d..4022fe7 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -161,13 +161,21 @@ int pthread_getschedparam_ex(pthread_t thread,
 
 COBALT_IMPL(int, sched_yield, (void))
 {
+   unsigned long status;
int ret;
 
+   status = cobalt_get_current_mode();
+   if (status  XNRELAX)
+   goto libc_yield;
+
ret = -XENOMAI_SKINCALL0(__cobalt_muxid, sc_cobalt_sched_yield);
if (ret == EPERM)
-   ret = __STD(sched_yield());
+   goto libc_yield;
 
return ret;
+
+libc_yield:
+   return __STD(sched_yield());
 }
 
 COBALT_IMPL(int, sched_get_priority_min, (int policy))


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


[Xenomai-git] Philippe Gerum : lib/cobalt: make relaxed threads [sched_]yield() to the regular kernel

2013-09-03 Thread git repository hosting
Module: xenomai-forge
Branch: next
Commit: 545d134bc17443651e3c94c673eba1f471cf
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=545d134bc17443651e3c94c673eba1f471cf

Author: Philippe Gerum r...@xenomai.org
Date:   Sat Aug 31 11:04:44 2013 +0200

lib/cobalt: make relaxed threads [sched_]yield() to the regular kernel

Calling sched_yield() from a relaxed context should yield control to
the regular kernel. There is no point in switching back to primary
mode for running Xenomai's yield service, which is most likely to
force a migration through the secondary mode yet again.

When the user code runs a tight loop yielding the CPU continuously
over a non-rt thread (i.e. WEAK scheduling), the overhead is
significantly lower.

---

 lib/cobalt/thread.c |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index 15a665d..4022fe7 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -161,13 +161,21 @@ int pthread_getschedparam_ex(pthread_t thread,
 
 COBALT_IMPL(int, sched_yield, (void))
 {
+   unsigned long status;
int ret;
 
+   status = cobalt_get_current_mode();
+   if (status  XNRELAX)
+   goto libc_yield;
+
ret = -XENOMAI_SKINCALL0(__cobalt_muxid, sc_cobalt_sched_yield);
if (ret == EPERM)
-   ret = __STD(sched_yield());
+   goto libc_yield;
 
return ret;
+
+libc_yield:
+   return __STD(sched_yield());
 }
 
 COBALT_IMPL(int, sched_get_priority_min, (int policy))


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