DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T f

⟦341164f56⟧ TextFile

    Length: 742 (0x2e6)
    Types: TextFile
    Names: »forkes.c«

Derivation

└─⟦db229ac7e⟧ Bits:30007240 EUUGD20: SSBA 1.2 / AFW Benchmarks
    └─⟦this⟧ »EUUGD20/AFUU-ssba1.21/ssba1.21E/bsd/forkes.c« 
    └─⟦this⟧ »EUUGD20/AFUU-ssba1.21/ssba1.21F/bsd/forkes.c« 

TextFile

main(argc, argv)
	char	*argv[];
{
	register int nforks, i;
	char *cp;
	int pid,child,status,brksize;

	if (argc < 2){
		printf("usage : %s number-of-forks sbrk-size \n", argv[0]);
		exit(1);
	}
	nforks = atoi(argv[1]);
	if (nforks < 0 ){
		printf("%s: bad number of forks \n", argv[1]);
		exit(2);
	}
	brksize = atoi(argv[2]);
	if (brksize < 0 ){
		printf("%s: bad size to sbrk \n", argv[2]);
		exit(3);
	}
	cp = (char *) sbrk(brksize);
	if((int)cp == -1){
		perror("sbrk");
		exit(4);
	}
	for (i = 0; i < brksize; i += 1024)
		cp[i] = i;
	while (nforks-- > 0){
		child = fork();
		if (child == -1){
			perror("fork");
			exit(-1);
		}
		if (child == 0)
			exit(-1);
		while((pid = wait(&status)) != -1 && pid != child)
				;
	}
	exit(0);
}