[Xenomai-git] Philippe Gerum : testsuite/latency: fix false positive in mode switch detection
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 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
[Xenomai-git] Philippe Gerum : testsuite/latency: fix false positive in mode switch detection
Module: xenomai-2.5 Branch: master Commit: eb7875f2094a57a7eee68adbe1d3accc6e0fc7e2 URL: http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=eb7875f2094a57a7eee68adbe1d3accc6e0fc7e2 Author: Philippe Gerum 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
[Xenomai-git] Philippe Gerum : testsuite/latency: fix false positive in mode switch detection
Module: xenomai-rpm Branch: for-upstream Commit: 9be1830070b705c7a00139814ed50c385bd0c8e1 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=9be1830070b705c7a00139814ed50c385bd0c8e1 Author: Philippe Gerum 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
[Xenomai-git] Philippe Gerum : testsuite/latency: fix false positive in mode switch detection
Module: xenomai-rpm Branch: for-upstream Commit: 466d810ac9b61b06eaa9cb28815d95f063084fb8 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=466d810ac9b61b06eaa9cb28815d95f063084fb8 Author: Philippe Gerum Date: Wed Mar 10 11:44:34 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, ignore it. Masking SIGINT for the sampling task would require an initial mode switch we might not want to perform either. --- src/testsuite/latency/latency.c | 15 +++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/src/testsuite/latency/latency.c b/src/testsuite/latency/latency.c index 4df8e7f..08f9c19 100644 --- a/src/testsuite/latency/latency.c +++ b/src/testsuite/latency/latency.c @@ -437,6 +437,21 @@ void cleanup(void) void sighand(int sig __attribute__ ((unused))) { + RT_TASK *me; + + if (sig == SIGINT) { + /* +* Receiving SIGINT on the sampling task must have +* caused a mode switch notification earlier. This is +* a false positive wrt involuntary mode switch +* reporting, ignore it. +*/ + me = rt_task_self(); + if (me && rt_task_same(me, &latency_task) && + sampling_relaxed > 0) + sampling_relaxed--; + } + finished = 1; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git