Module: xenomai-2.5
Branch: master
Commit: 9be1830070b705c7a00139814ed50c385bd0c8e1
URL:    
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=9be1830070b705c7a00139814ed50c385bd0c8e1

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Mar 10 12:13:46 2010 +0100

testsuite/latency: fix false positive in mode switch detection

When ^C is depressed to stop the test, receiving SIGINT on the
sampling task must have caused a mode switch notification
earlier. This is a false positive wrt involuntary mode switch
reporting.

To avoid this, block SIGINT (and most termination signals altogether)
for test threads, and receive them explicitely on the main thread via
sigwait().

---

 src/testsuite/latency/latency.c |   27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/src/testsuite/latency/latency.c b/src/testsuite/latency/latency.c
index 4df8e7f..e9e741e 100644
--- a/src/testsuite/latency/latency.c
+++ b/src/testsuite/latency/latency.c
@@ -435,11 +435,6 @@ void cleanup(void)
        exit(0);
 }
 
-void sighand(int sig __attribute__ ((unused)))
-{
-       finished = 1;
-}
-
 void faulthand(int sig)
 {
        xntrace_user_freeze(0, 1);
@@ -451,12 +446,11 @@ void mode_sw(int sig)
 {
 #ifndef __UCLIBC__
        const char buffer[] = "Mode switch, aborting. Backtrace:\n";
+       static void *bt[200];
 #else /* __UCLIBC__ */
        const char buffer[] = "Mode switch, aborting."
                " Backtrace unavailable with uclibc.\n";
 #endif /* __UCLIBC__ */
-       
-       static void *bt[200];
        unsigned n;
 
        if (!stop_upon_switch) {
@@ -476,9 +470,9 @@ void mode_sw(int sig)
 
 int main(int argc, char **argv)
 {
-       int c, err;
+       int cpu = 0, c, err, sig;
        char task_name[16];
-       int cpu = 0;
+       sigset_t mask;
 
        while ((c = getopt(argc, argv, "hp:l:T:qH:B:sD:t:fc:P:b")) != EOF)
                switch (c) {
@@ -600,10 +594,13 @@ int main(int argc, char **argv)
        else if (priority > T_HIPRIO)
                priority = T_HIPRIO;
 
-       signal(SIGINT, sighand);
-       signal(SIGTERM, sighand);
-       signal(SIGHUP, sighand);
-       signal(SIGALRM, sighand);
+       sigemptyset(&mask);
+       sigaddset(&mask, SIGINT);
+       sigaddset(&mask, SIGTERM);
+       sigaddset(&mask, SIGHUP);
+       sigaddset(&mask, SIGALRM);
+       pthread_sigmask(SIG_BLOCK, &mask, NULL);
+
        signal(SIGXCPU, mode_sw);
 
        if (freeze_max) {
@@ -681,8 +678,8 @@ int main(int argc, char **argv)
                }
        }
 
-       while (!finished)
-               pause();
+       sigwait(&mask, &sig);
+       finished = 1;
 
        cleanup();
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to