Gilles Chanteperdrix wrote:
 > Landau, Bracha wrote:
 >  > I'm using xenomai 2.2 rc3 on a MPC8247, on linux 2.6.14.
 >  >  
 >  > I have a problem using mq_open. Please see the attached code.
 >  > If I fork before the mq_open the kernel, I get a kernel oops.
 >  > 
 >  > Why this behaviour?
 > 
 > The child process has not "bound" the interface, so, it has no
 > per-process data. If this is the cause of the oops, the solution is to
 > add a pthread_atfork call in xeno_user_skin_init in order for the
 > process children to also call xeno_user_skin_init.

Actually, this issue is specific to skins using the per-process data
feature, i.e. only the posix skin now. So, here is a fix that only fixes
the posix skin initialization. If it solve your issue I will commit it.
You only have to rebuild the user-space support, kernel-space support is
unchanged.

-- 


                                            Gilles Chanteperdrix.
Index: src/skins/posix/init.c
===================================================================
--- src/skins/posix/init.c      (revision 1357)
+++ src/skins/posix/init.c      (working copy)
@@ -30,6 +30,7 @@
 int __pse51_muxid = -1;
 int __rtdm_muxid = -1;
 int __rtdm_fd_start = INT_MAX;
+static int fork_handler_registered;
 
 int __wrap_pthread_setschedparam(pthread_t, int, const struct sched_param *);
 
@@ -58,9 +59,9 @@
        }
 
        parm.sched_priority = 0;
-       if ((err =
-            __wrap_pthread_setschedparam(pthread_self(), SCHED_OTHER,
-                                         &parm))) {
+       err = __wrap_pthread_setschedparam(pthread_self(), SCHED_OTHER,
+                                          &parm);
+       if (err) {
                fprintf(stderr, "Xenomai Posix skin init: "
                        "pthread_setschedparam: %s\n", strerror(err));
                exit(EXIT_FAILURE);
@@ -70,4 +71,14 @@
                perror("Xenomai Posix skin init: munlockall");
                exit(EXIT_FAILURE);
        }
+
+       if (!fork_handler_registered) {
+               err = pthread_atfork(NULL, NULL, &__init_posix_interface);
+               if (err) {
+                       fprintf(stderr, "Xenomai Posix skin init: "
+                               "pthread_atfork: %s\n", strerror(err));
+                       exit(EXIT_FAILURE);
+               }
+               fork_handler_registered = 1;
+       }
 }
Index: src/testsuite/switchtest/Makefile.am
===================================================================
--- src/testsuite/switchtest/Makefile.am        (revision 1357)
+++ src/testsuite/switchtest/Makefile.am        (working copy)
@@ -9,8 +9,7 @@
 switch_LDFLAGS =  $(XENO_POSIX_WRAPPERS) $(XENO_USER_LDFLAGS)
 
 switch_LDADD = \
-       -lpthread -lrt \
-       ../../skins/posix/.libs/libpthread_rt.a
+       ../../skins/posix/.libs/libpthread_rt.a -lpthread -lrt
 
 install-data-local:
        $(mkinstalldirs) $(DESTDIR)$(testdir)
Index: src/testsuite/switchtest/Makefile.in
===================================================================
--- src/testsuite/switchtest/Makefile.in        (revision 1357)
+++ src/testsuite/switchtest/Makefile.in        (working copy)
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(switch_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
@@ -229,8 +231,7 @@
 switch_CPPFLAGS = -I$(top_srcdir)/include/posix $(XENO_USER_CFLAGS) -g 
-I$(top_srcdir)/include
 switch_LDFLAGS = $(XENO_POSIX_WRAPPERS) $(XENO_USER_LDFLAGS)
 switch_LDADD = \
-       -lpthread -lrt \
-       ../../skins/posix/.libs/libpthread_rt.a
+       ../../skins/posix/.libs/libpthread_rt.a -lpthread -lrt
 
 EXTRA_DIST = runinfo
 all: all-am
Index: src/testsuite/cyclic/Makefile.am
===================================================================
--- src/testsuite/cyclic/Makefile.am    (revision 1357)
+++ src/testsuite/cyclic/Makefile.am    (working copy)
@@ -9,8 +9,7 @@
 cyclictest_LDFLAGS = $(XENO_POSIX_WRAPPERS) $(XENO_USER_LDFLAGS)
 
 cyclictest_LDADD = \
-       -lpthread -lrt \
-       ../../skins/posix/.libs/libpthread_rt.a
+       ../../skins/posix/.libs/libpthread_rt.a -lpthread -lrt
 
 install-data-local:
        $(mkinstalldirs) $(DESTDIR)$(testdir)
Index: src/testsuite/cyclic/Makefile.in
===================================================================
--- src/testsuite/cyclic/Makefile.in    (revision 1357)
+++ src/testsuite/cyclic/Makefile.in    (working copy)
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(cyclictest_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
@@ -229,8 +231,7 @@
 cyclictest_CPPFLAGS = -I$(top_srcdir)/include/posix $(XENO_USER_CFLAGS) 
-DIPIPE_TRACE=1 -I$(top_srcdir)/include
 cyclictest_LDFLAGS = $(XENO_POSIX_WRAPPERS) $(XENO_USER_LDFLAGS)
 cyclictest_LDADD = \
-       -lpthread -lrt \
-       ../../skins/posix/.libs/libpthread_rt.a
+       ../../skins/posix/.libs/libpthread_rt.a -lpthread -lrt
 
 EXTRA_DIST = runinfo
 all: all-am
Index: src/testsuite/irqbench/Makefile.am
===================================================================
--- src/testsuite/irqbench/Makefile.am  (revision 1357)
+++ src/testsuite/irqbench/Makefile.am  (working copy)
@@ -19,8 +19,7 @@
        $(XENO_USER_LDFLAGS)
 
 irqloop_LDADD = \
-       -lpthread \
-       ../../skins/posix/.libs/libpthread_rt.a
+       ../../skins/posix/.libs/libpthread_rt.a -lpthread
 
 
 irqbench_SOURCES = irqbench.c
Index: src/testsuite/irqbench/Makefile.in
===================================================================
--- src/testsuite/irqbench/Makefile.in  (revision 1357)
+++ src/testsuite/irqbench/Makefile.in  (working copy)
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(irqbench_SOURCES) $(irqloop_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
@@ -241,8 +243,7 @@
        $(XENO_USER_LDFLAGS)
 
 irqloop_LDADD = \
-       -lpthread \
-       ../../skins/posix/.libs/libpthread_rt.a
+       ../../skins/posix/.libs/libpthread_rt.a -lpthread
 
 irqbench_SOURCES = irqbench.c
 irqbench_CPPFLAGS = \
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Reply via email to