Annotation of Net2/tests/benchmarks/vexecs.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Benchmark program to calculate exec
        !             3:  * overhead (approximately).  Process
        !             4:  * vforks and execs "null" test program.
        !             5:  * The time to run the vfork program should
        !             6:  * then be deducted from this one to
        !             7:  * estimate the overhead for the exec.
        !             8:  */
        !             9: 
        !            10: main(argc, argv)
        !            11:        char *argv[];
        !            12: {
        !            13:        register int nexecs, i;
        !            14:        char *cp, *sbrk();
        !            15:        int pid, child, status, brksize;
        !            16: 
        !            17:        if (argc < 3) {
        !            18:                printf("usage: %s number-of-execs sbrk-size job-name\n",
        !            19:                    argv[0]);
        !            20:                exit(1);
        !            21:        }
        !            22:        nexecs = atoi(argv[1]);
        !            23:        if (nexecs < 0) {
        !            24:                printf("%s: bad number of execs\n", argv[1]);
        !            25:                exit(2);
        !            26:        }
        !            27:        brksize = atoi(argv[2]);
        !            28:        if (brksize < 0) {
        !            29:                printf("%s: bad size to sbrk\n", argv[2]);
        !            30:                exit(3);
        !            31:        }
        !            32:        cp = sbrk();
        !            33:        if ((int)cp == -1) {
        !            34:                perror("sbrk");
        !            35:                exit(4);
        !            36:        }
        !            37:        for (i = 0; i < brksize; i += 1024)
        !            38:                cp[i] = i;
        !            39:        while (nexecs-- > 0) {
        !            40:                child = vfork();
        !            41:                if (child == -1) {
        !            42:                        perror("vfork");
        !            43:                        exit(-1);
        !            44:                }
        !            45:                if (child == 0) {
        !            46:                        execv(argv[3], argv);
        !            47:                        perror("execv");
        !            48:                        _exit(-1);
        !            49:                }
        !            50:                while ((pid = wait(&status)) != -1 && pid != child)
        !            51:                        ;
        !            52:        }
        !            53:        exit(0);
        !            54: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.