All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: Dmitry Adamushko <dmitry.adamushko@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-core] [PATCH 6/6] Introduce IRQ latency benchmark
Date: Wed, 28 Jun 2006 16:37:29 +0200	[thread overview]
Message-ID: <44A29429.4060609@domain.hid> (raw)
In-Reply-To: <b647ffbd0606280714q142553dag79cd39c4068992e8@domain.hid>


[-- Attachment #1.1: Type: text/plain, Size: 1766 bytes --]

Dmitry Adamushko wrote:
> On 28/06/06, Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote:
>> Jan Kiszka wrote:
>>  >
>>  > Ok, then we also need a fix for the latency test (this is where I
>>  > grabbed that pattern from). Is there a high risk that this locks up? I
>>  > wonder why I never observed or heard of problems with latency.
>>
>> The latency test used to deadlock, that is why the summary printed on
>> signal is printed on stderr. Unfortunately, there seem to be one display
>> left on stdout, so it should still deadlock. The reason why we never see
>> the deadlock is (perhaps) that the continuous intermediate results are
>> printed on the context of the "display" thread, whereas the termination
>> signals are preferably delivered by the kernel to the "main" thread,
>> that only calls pause. Which makes the use of stderr in signals handlers
>> pointless.
> 
> It's very likely so.
> 
> The main thread would use instead something like :
> ...
> while (!sig_term_received)
>    pause();
> 
> do_cleanup_chores();
> return 0;
> 
> cleanup_upon_sig() should only set the sig_term_received flag up.
> 
> Then all other threads must block signal delivering with sigprocmask()
> so that the main thread is the only one which "accepts" signals.

Is that required, i.e. does pause() only wake up if the signal handler
executed in the main thread's context? Then cyclictest contains a bug as
well...

> 
> btw, according to POSIX 1003.1-2003, the write() call is amongst "safe"
> ones.
> http://www.die.net/doc/linux/man/man2/signal.2.html
> 
> So write(1, ....); heh... not that nice? :)
> 
> 

Something like this? Developed on top of my prio-switch patch. So far
without signal masking.

Jan

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: fix-printf-from-sig.patch --]
[-- Type: text/x-patch; name="fix-printf-from-sig.patch", Size: 3542 bytes --]

---
 src/testsuite/latency/latency.c |   46 ++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 22 deletions(-)

Index: xenomai/src/testsuite/latency/latency.c
===================================================================
--- xenomai.orig/src/testsuite/latency/latency.c
+++ xenomai/src/testsuite/latency/latency.c
@@ -293,7 +293,7 @@ double dump_histogram (long *histogram, 
     double avg = 0;             /* used to sum hits 1st */
 
     if (do_histogram)
-        fprintf(stderr,"---|--param|----range-|--samples\n");
+        printf("---|--param|----range-|--samples\n");
 
     for (n = 0; n < histogram_size; n++)
         {
@@ -304,12 +304,11 @@ double dump_histogram (long *histogram, 
             total_hits += hits;
             avg += n * hits;
             if (do_histogram)
-                fprintf(stderr,
-                        "HSD|    %s| %3d -%3d | %8ld\n",
-                        kind,
-                        n,
-                        n+1,
-                        hits);
+                printf("HSD|    %s| %3d -%3d | %8ld\n",
+                       kind,
+                       n,
+                       n+1,
+                       hits);
             }
         }
 
@@ -338,8 +337,8 @@ void dump_stats (long *histogram, char* 
     variance /= total_hits - 1;
     variance = sqrt(variance);
 
-    fprintf(stderr,"HSS|    %s| %9d| %10.3f| %10.3f\n",
-            kind, total_hits, avg, variance);
+    printf("HSS|    %s| %9d| %10.3f| %10.3f\n",
+           kind, total_hits, avg, variance);
 }
 
 void dump_hist_stats (void)
@@ -351,23 +350,18 @@ void dump_hist_stats (void)
     avgavg = dump_histogram (histogram_avg, "avg");
     maxavg = dump_histogram (histogram_max, "max");
 
-    fprintf(stderr,"HSH|--param|--samples-|--average--|---stddev--\n");
+    printf("HSH|--param|--samples-|--average--|---stddev--\n");
 
     dump_stats (histogram_min, "min", minavg);
     dump_stats (histogram_avg, "avg", avgavg);
     dump_stats (histogram_max, "max", maxavg);
 }
 
-void cleanup_upon_sig(int sig __attribute__((unused)))
+void cleanup(void)
 {
     time_t actual_duration;
     long gmaxj, gminj, gavgj;
 
-    if (finished)
-        return;
-
-    finished = 1;
-
     if (test_mode == USER_TASK) {
         rt_sem_delete(&display_sem);
 
@@ -421,6 +415,11 @@ void cleanup_upon_sig(int sig __attribut
     exit(0);
 }
 
+void sighand(int sig __attribute__((unused)))
+{
+    finished = 1;
+}
+
 int main (int argc, char **argv)
 {
     int c, err;
@@ -532,7 +531,7 @@ int main (int argc, char **argv)
     histogram_min = calloc(histogram_size, sizeof(long));
 
     if (!(histogram_avg && histogram_max && histogram_min)) 
-        cleanup_upon_sig(0);
+        cleanup();
 
     if (period_ns == 0)
         period_ns = 100000LL; /* ns */
@@ -542,10 +541,10 @@ int main (int argc, char **argv)
     else if (priority > T_HIPRIO)
         priority = T_HIPRIO;
 
-    signal(SIGINT, cleanup_upon_sig);
-    signal(SIGTERM, cleanup_upon_sig);
-    signal(SIGHUP, cleanup_upon_sig);
-    signal(SIGALRM, cleanup_upon_sig);
+    signal(SIGINT, sighand);
+    signal(SIGTERM, sighand);
+    signal(SIGHUP, sighand);
+    signal(SIGALRM, sighand);
 
     setlinebuf(stdout);
 
@@ -610,7 +609,10 @@ int main (int argc, char **argv)
             }
     }
 
-    pause();
+    while (!finished)
+        pause();
+
+    cleanup();
 
     return 0;
 }

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

  reply	other threads:[~2006-06-28 14:37 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-26 17:21 [Xenomai-core] [PATCH 0/6] Various refactoring and new IRQ test jan.kiszka
2006-06-26 17:21 ` [Xenomai-core] [PATCH 1/6] Refactor tracer API jan.kiszka
2006-06-26 17:21 ` [Xenomai-core] [PATCH 2/6] Improve fault report jan.kiszka
2006-06-28  7:42   ` Philippe Gerum
2006-06-28  7:51     ` Jan Kiszka
2006-06-28  8:04       ` Philippe Gerum
2006-06-28  8:18         ` Jan Kiszka
2006-06-28  8:36           ` Philippe Gerum
2006-06-28  8:51             ` Jan Kiszka
2006-06-28  9:00               ` Philippe Gerum
2006-06-28  9:17                 ` Jan Kiszka
2006-06-28 16:36                   ` Philippe Gerum
2006-06-26 17:21 ` [Xenomai-core] [PATCH 3/6] Refactor rttesting device interface jan.kiszka
2006-06-26 17:21 ` [Xenomai-core] [PATCH 4/6] Add prio switch to latency test jan.kiszka
2006-06-28 19:38   ` Jan Kiszka
2006-06-26 17:21 ` [Xenomai-core] [PATCH 5/6] Overread dev-prefix on posix open jan.kiszka
2006-06-28 19:38   ` Jan Kiszka
2006-06-26 17:21 ` [Xenomai-core] [PATCH 6/6] Introduce IRQ latency benchmark jan.kiszka
2006-06-27 16:45   ` Jan Kiszka
2006-06-28 12:11   ` Gilles Chanteperdrix
2006-06-28 12:28     ` Jan Kiszka
2006-06-28 12:35       ` Gilles Chanteperdrix
2006-06-28 13:42       ` Gilles Chanteperdrix
2006-06-28 14:14         ` Dmitry Adamushko
2006-06-28 14:37           ` Jan Kiszka [this message]
2006-06-28 15:18             ` Dmitry Adamushko
2006-06-28 14:44         ` Jan Kiszka
2006-06-28 19:39   ` Jan Kiszka
2006-06-29 11:20     ` Jan Kiszka
2006-07-01 15:38       ` Philippe Gerum
2006-07-01 18:17         ` Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44A29429.4060609@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=dmitry.adamushko@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.