Module: xenomai-jki
Branch: for-upstream
Commit: f525ac510061af0aa1817deac1b2916847f4f02b
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=f525ac510061af0aa1817deac1b2916847f4f02b

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Tue Apr 23 14:04:16 2013 +0200

Invoke mlockall on every skin library initialization

The nucleus refuses to create threads if userspace didn't lock its
memory, that's the rule since day #1 basically. So far we require
userspace to do this explicitly, but there is actually nothing to lose
by doing it automatically during the initialization of a skin library.
In special scenarios, userspace could still temporarily unlock the
memory again.

As we lock unconditionally, there is no more need to lock/unlock around
POSIX auto-shadowing.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 src/skins/common/bind.c |    6 ++++++
 src/skins/posix/init.c  |   17 -----------------
 2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/src/skins/common/bind.c b/src/skins/common/bind.c
index c869795..aeef861 100644
--- a/src/skins/common/bind.c
+++ b/src/skins/common/bind.c
@@ -4,6 +4,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
+#include <sys/mman.h>
 
 #include <nucleus/heap.h>
 #include <asm/xenomai/syscall.h>
@@ -92,6 +93,11 @@ xeno_bind_skin_opt(unsigned skin_magic, const char *skin, 
const char *module)
                exit(EXIT_FAILURE);
        }
 
+       if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
+               perror("Xenomai: mlockall");
+               exit(EXIT_FAILURE);
+       }
+
        xeno_featinfo = finfo;
        xeno_init_arch_features();
 
diff --git a/src/skins/posix/init.c b/src/skins/posix/init.c
index 710abfb..36ef397 100644
--- a/src/skins/posix/init.c
+++ b/src/skins/posix/init.c
@@ -68,16 +68,6 @@ void __init_posix_interface(void)
                                                                 
__rtdm_fdcount);
        }
 
-       /* If not dlopening, we are going to shadow the main thread, so mlock
-          the whole memory for the time of the syscall, in order to avoid the
-          SIGXCPU signal. */
-#if defined(CONFIG_XENO_POSIX_AUTO_MLOCKALL) || 
!defined(CONFIG_XENO_LIBS_DLOPEN)
-       if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
-               perror("Xenomai Posix skin init: mlockall");
-               exit(EXIT_FAILURE);
-       }
-#endif /* auto mlockall || !dlopen */
-
        /* Don't use auto-shadowing if we are likely invoked from dlopen. */
 #ifndef CONFIG_XENO_LIBS_DLOPEN
        err = __real_pthread_getschedparam(pthread_self(), &policy, &parm);
@@ -93,13 +83,6 @@ void __init_posix_interface(void)
                        "pthread_setschedparam: %s\n", strerror(err));
                exit(EXIT_FAILURE);
        }
-
-#ifndef CONFIG_XENO_POSIX_AUTO_MLOCKALL
-       if (munlockall()) {
-               perror("Xenomai Posix skin init: munlockall");
-               exit(EXIT_FAILURE);
-       }
-#endif /* !CONFIG_XENO_POSIX_AUTO_MLOCKALL */
 #endif /* !CONFIG_XENO_LIBS_DLOPEN */
 
        if (fork_handler_registered)


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

Reply via email to