⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 execs.c

📁 早期freebsd实现
💻 C
字号:
/* * Benchmark program to calculate exec * overhead (approximately).  Process * forks and execs "null" test program. * The time to run the fork program should * then be deducted from this one to * estimate the overhead for the exec. */main(argc, argv)	char *argv[];{	register int nexecs, i;	char *cp, *sbrk();	int pid, child, status, brksize;	if (argc < 3) {		printf("usage: %s number-of-execs sbrk-size job-name\n",		    argv[0]);		exit(1);	}	nexecs = atoi(argv[1]);	if (nexecs < 0) {		printf("%s: bad number of execs\n", argv[1]);		exit(2);	}	brksize = atoi(argv[2]);	if (brksize < 0) {		printf("%s: bad size to sbrk\n", argv[2]);		exit(3);	}	cp = sbrk(brksize);	if ((int)cp == -1) {		perror("sbrk");		exit(4);	}	for (i = 0; i < brksize; i += 1024)		cp[i] = i;	while (nexecs-- > 0) {		child = fork();		if (child == -1) {			perror("fork");			exit(-1);		}		if (child == 0) {			execv(argv[3], argv);			perror("execv");			_exit(-1);		}		while ((pid = wait(&status)) != -1 && pid != child)			;	}	exit(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -