Messages in this thread | | | Date | Thu, 16 Sep 1999 01:43:00 +0200 (CEST) | From | Robert de Vries <> | Subject | Re: [PATCH] 2.3.18: siginfo data available for all signals |
| |
On Wed, 15 Sep 1999, Robert de Vries wrote:
> > In principle I approve, as long as it does not slow signal delivery. It > > was obviously intended to work this way all along. Sorry I haven't time > > to examine the code. > > This all depends on the speed of the slab allocator for the siginfo > structure and the initialisation of the structure. I guess that it's fast > because that was the reason for putting in the allocator in the first > place and making a special slab for the siginfo structures.
Now doing a small benchmark reveals that RT signals take a little bit longer to arrive than normal signals. I have written a small program to measure this in a 2.2.5-22 redhat std. kernel.
This gives me for 1000 signals the following numbers on a 166 MHz Pentium:
normal signal takes on average 7.9 microsecs RT signal takes on average 10.9 microsecs
The difference must be due to the queueing of the signal.
What does the community think?
Is the patch ok as is and is the 3 extra microsec a problem? (please run the test prog on your platform to give me an idea what kind of latencies you have on other archs/faster CPUs)
Or should I be more conservative in the patch and only put siginfo's in the queue when they are either RT or if they pass siginfo in the first place (all signals)?
Robert
-- Robert de Vries rhdv@rhdv.cistron.nl #include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <unistd.h> #include <signal.h>
#if 1 #define SIGNO SIGUSR1 /* normal signal */ #else #define SIGNO SIGRTMIN /* RT signal */ #endif
#define NOF_DELAY 1000
int delay[1000]; int idel; struct timeval start;
void handle_signal(int signal) { struct timeval end; int delta;
gettimeofday(&end, NULL); delta = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec);
delay[idel++] = delta; }
void print_hist(void) { #define HISTSIZE 1000
int hist[1000 + 1]; int i;
memset(hist, 0, sizeof(hist));
for (i = 0; i < NOF_DELAY; i++) { if (delay[i] >= HISTSIZE) { printf("sample %d over max hist: %d\n", i, delay[i]); hist[HISTSIZE]++; } else { hist[delay[i]]++; } } for (i = 0; i < HISTSIZE; i++) { if (hist[i]) { printf("%d: %d\n", i, hist[i]); } } printf("HC: %d\n", hist[HISTSIZE]); }
void print_avg(void) { double sum; int i;
sum = 0; for (i = 0; i < NOF_DELAY; i++) { sum += delay[i]; }
printf("avg. delay: %f\n", sum/NOF_DELAY); }
int main(void) { struct sigaction act; int i; pid_t p;
p = getpid();
act.sa_flags = 0; act.sa_handler = handle_signal; sigemptyset(&act.sa_mask);
if (sigaction(SIGNO, &act, NULL)) { perror("sigaction failed"); exit(1); }
for (i = 0; i < NOF_DELAY; i++) { gettimeofday(&start, NULL); kill(p, SIGNO); }
print_hist();
print_avg();
return 0; }
| |