Module: xenomai-3 Branch: next Commit: 17ba6d91ade9b8a3e1d0c132645d1e925cca3458 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=17ba6d91ade9b8a3e1d0c132645d1e925cca3458
Author: Philippe Gerum <[email protected]> Date: Tue Mar 1 08:36:18 2016 +0100 cobalt/thread: do not demote kthreads when cancelling There is no point in switching a kthread to weak scheduling when cancelling it, as it must reach a cancellation point asap as part of its work loop anyway. Would it omit testing for cancellation, weak scheduling would not help enforcing the exit request anyway. --- kernel/cobalt/thread.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index 26ce90f..2b0cf60 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -1562,16 +1562,21 @@ check_self_cancel: return; } - __xnthread_demote(thread); - /* - * A userland thread undergoing the weak scheduling policy is - * unlikely to issue Cobalt syscalls frequently, which may - * defer cancellation significantly: send it a regular - * termination signal too. + * Force the non-current thread to exit: + * + * - unblock a user thread, switch it to weak scheduling, + * then send it SIGTERM. + * + * - just unblock a kernel thread, it is expected to reach a + * cancellation point soon after + * (i.e. xnthread_test_cancel()). */ - if (xnthread_test_state(thread, XNWEAK|XNUSER) == (XNWEAK|XNUSER)) + if (xnthread_test_state(thread, XNUSER)) { + __xnthread_demote(thread); xnthread_signal(thread, SIGTERM, 0); + } else + __xnthread_kick(thread); out: xnlock_put_irqrestore(&nklock, s); _______________________________________________ Xenomai-git mailing list [email protected] https://xenomai.org/mailman/listinfo/xenomai-git
