lkml.org 
[lkml]   [1998]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: FreeBSD & Linux [./fork 500 totally hangs my machine 2.1.127]
    Date
    From
    The fork call returns -1 and then you kill -1.
    You must be running as root!!!!

    Allen

    >>>"Hans Eric =?ISO-8859-1?Q?Sandstr=F6m" ?= said:
    > Hans Eric Sandström wrote:
    >
    > > Sher Pavel A. wrote:
    > >
    > > > Can somebody tell me why this program under FreeBSD works much more fast
    er
    > > > then under Linux ?
    > > >
    >
    > I did put in one sleep and tested on my macine:
    > ./fork 100 - 1 sec
    > ./fork 200 - 2 sec
    > ./fork 300 - 2 sec
    > ./fork 400 - 3 sec
    > ./fork 500 *** My machine totally hangs.
    >
    > Please Alan, Can you explain this or is this some bug in the kernel??
    >
    > -- Moified fork.c program.
    > #include <stdio.h>
    > #include <unistd.h>
    > #include <time.h>
    > #include <stdlib.h>
    > #include <sys/types.h>
    > #include <signal.h>
    >
    > void main(int argc, char *argv[])
    > {
    > unsigned int num, i, st;
    > time_t new_time, old_time;
    > int *pid;
    >
    > if (argc < 2) {
    > printf("Usage: fork nnn\n");
    > _exit(0);
    > }
    > num=atoi(argv[1]);
    > pid=malloc(sizeof(int)*num);
    > old_time=time(NULL);
    > for (i=0; i<num; i++) {
    > st=fork();
    > if (st == 0) {
    > while (1) {
    > sleep(1);
    > printf("Process %i got one tick.\n", i);
    > }
    > _exit(0);
    > }
    > pid[i]=st;
    > printf("Process %i started.\n", i);
    > }
    > for (i=0; i<num; i++) {
    > kill(pid[i], SIGKILL);
    > printf("Process %i killed.\n", i);
    > }
    > new_time=time(NULL);
    > printf("Total time to spawn and kill %i processes : %i\n", num,
    > new_time-old_time);
    > }
    >
    >
    >
    > -
    > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    > the body of a message to majordomo@vger.rutgers.edu
    > Please read the FAQ at http://www.tux.org/lkml/

    ---------------------------------
    G. Allen Morris III

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

    \
     
     \ /
      Last update: 2005-03-22 13:45    [W:0.022 / U:122.556 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site