|
|
1.1 ! root 1: /* ! 2: * IPC benchmarkl, ! 3: * write and discard using pipes. ! 4: */ ! 5: ! 6: main(argc, argv) ! 7: char *argv[]; ! 8: { ! 9: char buf[512]; ! 10: int fd[2], msgsize; ! 11: register int i, iter; ! 12: ! 13: if (argc < 3) { ! 14: printf("usage: %s iterations message-size\n", argv[0]); ! 15: exit(1); ! 16: } ! 17: argc--, argv++; ! 18: iter = atoi(*argv); ! 19: argc--, argv++; ! 20: msgsize = atoi(*argv); ! 21: if (msgsize > sizeof (buf) || msgsize <= 0) { ! 22: printf("%s: Bad message size.\n", *argv); ! 23: exit(2); ! 24: } ! 25: if (pipe(fd) < 0) { ! 26: perror("pipe"); ! 27: exit(3); ! 28: } ! 29: if (fork() == 0) ! 30: for (i = 0; i < iter; i++) ! 31: read(fd[0], buf, msgsize); ! 32: else ! 33: for (i = 0; i < iter; i++) ! 34: write(fd[1], buf, msgsize); ! 35: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.