|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T t
Length: 2313 (0x909) Types: TextFile Names: »ttychk.c«
└─⟦db229ac7e⟧ Bits:30007240 EUUGD20: SSBA 1.2 / AFW Benchmarks └─⟦this⟧ »EUUGD20/AFUU-ssba1.21/ssba1.21E/musbus/ttychk.c« └─⟦this⟧ »EUUGD20/AFUU-ssba1.21/ssba1.21F/musbus/ttychk.c«
/* * * Checks for tty accessability and bandwidth saturation. * * $Header: ttychk.c,v 5.2 87/12/09 16:57:02 kenj Exp $ */ #include <stdio.h> #include "../install/signal.h" #ifdef TERMIO #include <termio.h> #define sgttyb termio #define TIOCGETP TCGETA #define sg_ospeed c_cflag #else #include <sgtty.h> #endif #ifndef CBAUD #define CBAUD 0017 /* masque speed */ #endif struct { int baud; /* baud rate */ int symb; /* symbolic constant for baud rate */ } bmap[] = { { 300, B300 }, { 1200, B1200 }, { 2400, B2400 }, { 4800, B4800 }, { 9600, B9600 }, { 0, 0 } }; int status = 0; /* exit() status */ main(argc, argv) int argc; char *argv[]; { struct sgttyb ttyb; int nusers; /* number of simulated users */ int need; /* max ttys that could be used */ int baud = 0; /* aggregate baud rate across active ttys */ int br; int nttys = 0; /* number of required ttys */ int i; int fd; int l; float orate; /* estimated output rate per user */ int onalarm(); if (argc < 4) { fprintf(stderr, "Usage: ttychk nusers orate ttydev ... \n"); exit(1); } nusers = atoi(argv[1]); if (nusers < 1) { fprintf(stderr, "ttychk: nusers must be > 0\n"); status |= 1; } sscanf(argv[2], "%f", &orate); need = nusers; signal(SIGALRM, onalarm); for (i = 3; i < argc && need; i++, nttys++, need--) { alarm(3); if ((fd = open(argv[i], 1)) < 0) { fprintf(stderr, "ttychk: cannot open %s for writing\n", argv[i]); perror(""); status |= 1; continue; } alarm(0); if (ioctl(fd, TIOCGETP, &ttyb) < 0) { fprintf(stderr, "ttychk: cannot stat %s\n", argv[i]); perror(""); status |= 1; close(fd); continue; } close(fd); br = 0; for (l = 0; bmap[l].baud; l++) { if (bmap[l].symb == (ttyb.sg_ospeed & CBAUD)) { br = bmap[l].baud; break; } } if (br != 9600) fprintf(stderr, "ttychk: Warning - baud rate at %d for %s\n", br, argv[i]); baud += br; } /* assume 10 bits per character, and the 80% figure is arbitrary! */ if (nusers*orate > 0.8*(baud/10)) { fprintf(stderr, "ttychk panic: Total tty output rate (%d chars/sec) exceeds 80%% of\n total tty bandwidth (%d chars/sec)\n", (int)(nusers*orate), baud/10); status |= 1; } exit(status); } onalarm() { status |= 1; }