[Xenomai-core] [PATCH 3/6] POSIX: Optimize pthread_setschedparam fast path
Optimize __wrap_pthread_setschedparam without HAVE___THREAD for the case that an already mapped shadow is modifying its own scheduling parameters. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- src/skins/posix/thread.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/src/skins/posix/thread.c b/src/skins/posix/thread.c index 2ecb64f..d2839c6 100644 --- a/src/skins/posix/thread.c +++ b/src/skins/posix/thread.c @@ -37,11 +37,10 @@ static int linuxthreads; int __wrap_pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param) { - pthread_t myself = pthread_self(); unsigned long *mode_buf = NULL; int err, promoted; - if (thread == myself) { + if (xeno_current != XN_NO_HANDLE thread == pthread_self()) { #ifdef HAVE___THREAD mode_buf = xeno_init_current_mode(); #else /* !HAVE___THREAD */ ___ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core
Re: [Xenomai-core] [PATCH 3/6] POSIX: Optimize pthread_setschedparam fast path
Jan Kiszka wrote: Optimize __wrap_pthread_setschedparam without HAVE___THREAD for the case that an already mapped shadow is modifying its own scheduling parameters. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- src/skins/posix/thread.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/src/skins/posix/thread.c b/src/skins/posix/thread.c index 2ecb64f..d2839c6 100644 --- a/src/skins/posix/thread.c +++ b/src/skins/posix/thread.c @@ -37,11 +37,10 @@ static int linuxthreads; int __wrap_pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param) { - pthread_t myself = pthread_self(); unsigned long *mode_buf = NULL; int err, promoted; - if (thread == myself) { + if (xeno_current != XN_NO_HANDLE thread == pthread_self()) { I was under the impression that xeno_current was only correct with HAVE__THREAD. Otherwise, I guess we should use xeno_get_current(), no? -- Gilles. ___ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core
Re: [Xenomai-core] [PATCH 3/6] POSIX: Optimize pthread_setschedparam fast path
Gilles Chanteperdrix wrote: Jan Kiszka wrote: Optimize __wrap_pthread_setschedparam without HAVE___THREAD for the case that an already mapped shadow is modifying its own scheduling parameters. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- src/skins/posix/thread.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/src/skins/posix/thread.c b/src/skins/posix/thread.c index 2ecb64f..d2839c6 100644 --- a/src/skins/posix/thread.c +++ b/src/skins/posix/thread.c @@ -37,11 +37,10 @@ static int linuxthreads; int __wrap_pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param) { -pthread_t myself = pthread_self(); unsigned long *mode_buf = NULL; int err, promoted; -if (thread == myself) { +if (xeno_current != XN_NO_HANDLE thread == pthread_self()) { I was under the impression that xeno_current was only correct with HAVE__THREAD. Otherwise, I guess we should use xeno_get_current(), no? Of course. --- Optimize __wrap_pthread_setschedparam without HAVE___THREAD for the case that an already mapped shadow is modifying its own scheduling parameters. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- src/skins/posix/thread.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/src/skins/posix/thread.c b/src/skins/posix/thread.c index 2ecb64f..46c49bf 100644 --- a/src/skins/posix/thread.c +++ b/src/skins/posix/thread.c @@ -37,11 +37,10 @@ static int linuxthreads; int __wrap_pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param) { - pthread_t myself = pthread_self(); unsigned long *mode_buf = NULL; int err, promoted; - if (thread == myself) { + if (xeno_get_current() != XN_NO_HANDLE thread == pthread_self()) { #ifdef HAVE___THREAD mode_buf = xeno_init_current_mode(); #else /* !HAVE___THREAD */ ___ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core
Re: [Xenomai-core] [PATCH 3/6] POSIX: Optimize pthread_setschedparam fast path
Jan Kiszka wrote: Gilles Chanteperdrix wrote: Jan Kiszka wrote: Optimize __wrap_pthread_setschedparam without HAVE___THREAD for the case that an already mapped shadow is modifying its own scheduling parameters. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- src/skins/posix/thread.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/src/skins/posix/thread.c b/src/skins/posix/thread.c index 2ecb64f..d2839c6 100644 --- a/src/skins/posix/thread.c +++ b/src/skins/posix/thread.c @@ -37,11 +37,10 @@ static int linuxthreads; int __wrap_pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param) { - pthread_t myself = pthread_self(); unsigned long *mode_buf = NULL; int err, promoted; - if (thread == myself) { + if (xeno_current != XN_NO_HANDLE thread == pthread_self()) { I was under the impression that xeno_current was only correct with HAVE__THREAD. Otherwise, I guess we should use xeno_get_current(), no? Of course. --- Optimize __wrap_pthread_setschedparam without HAVE___THREAD for the case that an already mapped shadow is modifying its own scheduling parameters. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- src/skins/posix/thread.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/src/skins/posix/thread.c b/src/skins/posix/thread.c index 2ecb64f..46c49bf 100644 --- a/src/skins/posix/thread.c +++ b/src/skins/posix/thread.c @@ -37,11 +37,10 @@ static int linuxthreads; int __wrap_pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param) { - pthread_t myself = pthread_self(); unsigned long *mode_buf = NULL; int err, promoted; - if (thread == myself) { + if (xeno_get_current() != XN_NO_HANDLE thread == pthread_self()) { Should not this be xeno_get_current() == XN_NO_HANDLE ? The thread has a chance to be promoted only if it is not already shadowed. -- Gilles. ___ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core
Re: [Xenomai-core] [PATCH 3/6] POSIX: Optimize pthread_setschedparam fast path
Gilles Chanteperdrix wrote: Jan Kiszka wrote: diff --git a/src/skins/posix/thread.c b/src/skins/posix/thread.c index 2ecb64f..46c49bf 100644 --- a/src/skins/posix/thread.c +++ b/src/skins/posix/thread.c @@ -37,11 +37,10 @@ static int linuxthreads; int __wrap_pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param) { -pthread_t myself = pthread_self(); unsigned long *mode_buf = NULL; int err, promoted; -if (thread == myself) { +if (xeno_get_current() != XN_NO_HANDLE thread == pthread_self()) { Should not this be xeno_get_current() == XN_NO_HANDLE ? The thread has a chance to be promoted only if it is not already shadowed. Oh, hell. Friday-evening-on-the-train hack that hasn't been checked as it was so obvious... - Optimize __wrap_pthread_setschedparam without HAVE___THREAD for the case that an already mapped shadow is modifying its own scheduling parameters. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- src/skins/posix/thread.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/src/skins/posix/thread.c b/src/skins/posix/thread.c index 2ecb64f..5e04082 100644 --- a/src/skins/posix/thread.c +++ b/src/skins/posix/thread.c @@ -37,11 +37,10 @@ static int linuxthreads; int __wrap_pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param) { - pthread_t myself = pthread_self(); unsigned long *mode_buf = NULL; int err, promoted; - if (thread == myself) { + if (xeno_get_current() == XN_NO_HANDLE thread == pthread_self()) { #ifdef HAVE___THREAD mode_buf = xeno_init_current_mode(); #else /* !HAVE___THREAD */ ___ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core