httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roy T. Fielding" <field...@kiwi.ICS.UCI.EDU>
Subject Re: [PATCH] murderous HUP
Date Tue, 18 Feb 1997 19:00:48 GMT
>What I would suggest is
>
>                long waittime = 4096;
>
>                while (((waitret = waitpid(pid, &status, WNOHANG)) == 0) &&
>                        (waittime > 0) && (waittime < 3000000)) {
>                       tv.tv_sec  = 0;
>                       tv.tv_usec = waittime;
>                       waittime << 3;
>                       select(0, NULL, NULL, NULL, &tv);
>                }

Urgle, never mind.  I've just discovered the usec clock on my Ultra1 runs
in nanoseconds.  Going back to the modulo stuff, I've tested the
following code:
==============================
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

int main (void)
{
     int srv;
     long waittime = 8192;
     struct timeval tv;

     printf("Start\n");
     while ((waittime > 0) && (waittime < 3000000)) {
        printf("%d\n", waittime);
        tv.tv_sec  = waittime/1000000;
        tv.tv_usec = waittime%1000000;
        waittime <<= 2;
        srv = select(0, NULL, NULL, NULL, &tv);
    }
    printf("End\n");
    exit(0);
}
==============================
and the result on my system is
% time a.out
Start
8192
32768
131072
524288
2097152
End
0.00u 0.02s 0:02.88 0.6%

The bizarre thing is that without the modulo (just using tv_usec), it is

0.00u 0.02s 0:00.74 2.7%

Anyway, 8192 and *4 seem to be reasonable values (on an Ultra 1, but the
printfs will slow it down to average).

.....Roy

Mime
View raw message