|
|
1.1 root 1: /*
2: * Benchmark program to calculate vfork+wait
3: * overhead (approximately). Process
4: * vvforks and exits while parent waits.
5: * The time to run this program is used
6: * in calculating exec overhead.
7: */
8:
9: main(argc, argv)
10: char *argv[];
11: {
12: register int nvforks, i;
13: char *cp;
14: int pid, child, status, brksize;
15:
16: if (argc < 2) {
17: printf("usage: %s number-of-vforks sbrk-size\n", argv[0]);
18: exit(1);
19: }
20: nvforks = atoi(argv[1]);
21: if (nvforks < 0) {
22: printf("%s: bad number of vforks\n", argv[1]);
23: exit(2);
24: }
25: brksize = atoi(argv[2]);
26: if (brksize < 0) {
27: printf("%s: bad size to sbrk\n", argv[2]);
28: exit(3);
29: }
30: cp = (char *)sbrk(brksize);
31: if ((int)cp == -1) {
32: perror("sbrk");
33: exit(4);
34: }
35: for (i = 0; i < brksize; i += 1024)
36: cp[i] = i;
37: while (nvforks-- > 0) {
38: child = vfork();
39: if (child == -1) {
40: perror("vfork");
41: exit(-1);
42: }
43: if (child == 0)
44: _exit(-1);
45: while ((pid = wait(&status)) != -1 && pid != child)
46: ;
47: }
48: exit(0);
49: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.