Re: 2.4.4 sluggish under fork load

From: Peter Osterlund (peter.osterlund@mailbox.swipnet.se)
Date: Sat Apr 28 2001 - 13:00:45 EST


John Kacur <jkacur@home.com> writes:

> >Peter Osterlund wrote:
> >>
> >> Another thing is that the bash loop "while true ; do /bin/true ; done" is
> >> not possible to interrupt with ctrl-c.
>
> > Same thing here.
>
> I'm not having any problems. Just a quick question, is everyone who is
> having a problem running with more than one cpu?

A clarification. The bash loop above doesn't cause any sluggishness on
my single cpu system. The non-working ctrl-c is probably just a bash
bug. The child process must eat some cpu time to provoke the
sluggishness, like in the following test program where the child busy
waits 100ms and then exits:

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/time.h>

int main(int argc, char* argv[])
{
    double childTime = 0.10;
    if (argc > 1)
        childTime = atof(argv[1]);

    for (;;) {
        int child = fork();
        if (child == -1) {
            printf("fork error\n");
            exit(0);
        } else if (child > 0) {
            while (waitpid(child, NULL, 0) != child)
                ;
            printf("."); fflush(stdout);
        } else {
            struct timeval tv1, tv2;
            double t;
            gettimeofday(&tv1, NULL);
            for (;;) {
                gettimeofday(&tv2, NULL);
                t = (tv2.tv_sec - tv1.tv_sec) +
                    (tv2.tv_usec - tv1.tv_usec) / 1000000.0;
                if (t > childTime)
                    break;
            }
            _exit(0);
        }
    }

    return 0;
}

-- 
Peter Österlund             peter.osterlund@mailbox.swipnet.se
Sköndalsvägen 35            http://home1.swipnet.se/~w-15919
S-128 66 Sköndal            +46 8 942647
Sweden

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Apr 30 2001 - 21:00:21 EST