Module: xenomai-forge Branch: next Commit: 9137bdfe0b0881d04750c8e92e065657e7a9538e URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=9137bdfe0b0881d04750c8e92e065657e7a9538e
Author: Philippe Gerum <r...@xenomai.org> Date: Fri Jun 6 15:24:02 2014 +0200 lib/cobalt: do not route relaxed threads to standard sched_yield() Doing so for real-time threads brings no upside, and uselessly delays switch back to primary mode. Conversely, this change makes sched_yield() act as a conforming call for Xenomai threads which may be helpful in some cases. Xenomai threads which belong to the weak scheduling policy still yield CPU via the regular sched_yield() service though, since they naturally run in relaxed mode, unless Cobalt wants them to temporarily run in primary mode (i.e. because they hold some critical resource). --- lib/cobalt/thread.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c index e8c8961..821bfe5 100644 --- a/lib/cobalt/thread.c +++ b/lib/cobalt/thread.c @@ -163,21 +163,11 @@ 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) - goto libc_yield; - - return ret; + if (cobalt_get_current() == XN_NO_HANDLE || + (cobalt_get_current_mode() & (XNWEAK|XNRELAX)) == (XNWEAK|XNRELAX)) + return __STD(sched_yield()); -libc_yield: - return __STD(sched_yield()); + return -XENOMAI_SKINCALL0(__cobalt_muxid, sc_cobalt_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