[Xenomai] [PATCH 4/6] lib/cobalt: Avoid requesting shadowing for remote threads

Jan Kiszka jan.kiszka at siemens.com
Mon Jul 16 18:37:52 CEST 2018


From: Jan Kiszka <jan.kiszka at siemens.com>

Fix pthread_setschedparam_ex that it does not suggests the core to map
the current thread if the target thread of the request is actually not
pthread_self(). The core will reject such requests now, but we should
avoid them in the first place so that we get a clear error code.

Signed-off-by: Jan Kiszka <jan.kiszka at siemens.com>
---
 lib/cobalt/thread.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index 62ca0a02d9..fac23109c1 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -607,7 +607,7 @@ int pthread_setschedparam_ex(pthread_t thread,
 {
 	int ret, promoted, std_policy;
 	struct sched_param std_param;
-	__u32 u_winoff;
+	__u32 u_winoff, *u_winoff_ptr;
 
 	/*
 	 * If we enter this call over a relaxed context, take the
@@ -637,9 +637,12 @@ int pthread_setschedparam_ex(pthread_t thread,
 			return ret;
 	}
 
+	/* only request promotion when this targets the current thread */
+	u_winoff_ptr = thread == pthread_self() ? &u_winoff : NULL;
+
 	ret = -XENOMAI_SYSCALL5(sc_cobalt_thread_setschedparam_ex,
 				thread, policy, param_ex,
-				&u_winoff, &promoted);
+				u_winoff_ptr, &promoted);
 
 	if (ret == 0 && promoted) {
 		cobalt_sigshadow_install_once();
-- 
2.16.4




More information about the Xenomai mailing list