diff options
author | ed <ed@FreeBSD.org> | 2008-08-20 08:31:58 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2008-08-20 08:31:58 +0000 |
commit | cc3116a9380fe32a751b584f3d8083698ccfba15 (patch) | |
tree | bd0c08a66997254385160ce71ea32029b99f99f9 /usr.sbin/pstat/pstat.c | |
parent | b49301b5cd9ff43a7af0bd9054d9d1a328c0d212 (diff) | |
download | FreeBSD-src-cc3116a9380fe32a751b584f3d8083698ccfba15.zip FreeBSD-src-cc3116a9380fe32a751b584f3d8083698ccfba15.tar.gz |
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
Diffstat (limited to 'usr.sbin/pstat/pstat.c')
-rw-r--r-- | usr.sbin/pstat/pstat.c | 140 |
1 files changed, 53 insertions, 87 deletions
diff --git a/usr.sbin/pstat/pstat.c b/usr.sbin/pstat/pstat.c index a15292b..51828cb 100644 --- a/usr.sbin/pstat/pstat.c +++ b/usr.sbin/pstat/pstat.c @@ -214,7 +214,7 @@ static const char fhdr64[] = /* c000000000000000 ------ RWAI 123 123 c000000000000000 1000000000000000 */ static const char hdr[] = -" LINE RAW CAN OUT IHIWT ILOWT OHWT LWT COL STATE SESS PGID DISC\n"; +" LINE INQ CAN LIN LOW OUTQ USE LOW COL SESS PGID STATE\n"; static void ttymode_kvm(void) @@ -232,18 +232,18 @@ ttymode_kvm(void) while (tp != NULL) { if (kvm_read(kd, (u_long)tp, &tty, sizeof tty) != sizeof tty) errx(1, "kvm_read(): %s", kvm_geterr(kd)); - xt.xt_rawcc = tty.t_rawq.c_cc; - xt.xt_cancc = tty.t_canq.c_cc; - xt.xt_outcc = tty.t_outq.c_cc; -#define XT_COPY(field) xt.xt_##field = tty.t_##field - XT_COPY(line); - XT_COPY(state); - XT_COPY(column); - XT_COPY(ihiwat); - XT_COPY(ilowat); - XT_COPY(ohiwat); - XT_COPY(olowat); -#undef XT_COPY + xt.xt_insize = tty.t_inq.ti_nblocks * TTYINQ_DATASIZE; + xt.xt_incc = tty.t_inq.ti_linestart - tty.t_inq.ti_begin; + xt.xt_inlc = tty.t_inq.ti_end - tty.t_inq.ti_linestart; + xt.xt_inlow = tty.t_inlow; + xt.xt_outsize = tty.t_outq.to_nblocks * TTYOUTQ_DATASIZE; + xt.xt_outcc = tty.t_outq.to_end - tty.t_outq.to_begin; + xt.xt_outlow = tty.t_outlow; + xt.xt_column = tty.t_column; + /* xt.xt_pgid = ... */ + /* xt.xt_sid = ... */ + xt.xt_flags = tty.t_flags; + xt.xt_dev = NODEV; ttyprt(&xt); tp = TAILQ_NEXT(&tty, t_list); } @@ -287,95 +287,61 @@ static struct { int flag; char val; } ttystates[] = { -#ifdef TS_WOPEN - { TS_WOPEN, 'W'}, -#endif - { TS_ISOPEN, 'O'}, - { TS_CARR_ON, 'C'}, -#ifdef TS_CONNECTED - { TS_CONNECTED, 'c'}, -#endif - { TS_TIMEOUT, 'T'}, - { TS_FLUSH, 'F'}, - { TS_BUSY, 'B'}, -#ifdef TS_ASLEEP - { TS_ASLEEP, 'A'}, -#endif -#ifdef TS_SO_OLOWAT - { TS_SO_OLOWAT, 'A'}, -#endif -#ifdef TS_SO_OCOMPLETE - { TS_SO_OCOMPLETE, 'a'}, -#endif - { TS_XCLUDE, 'X'}, - { TS_TTSTOP, 'S'}, -#ifdef TS_CAR_OFLOW - { TS_CAR_OFLOW, 'm'}, -#endif -#ifdef TS_CTS_OFLOW - { TS_CTS_OFLOW, 'o'}, -#endif -#ifdef TS_DSR_OFLOW - { TS_DSR_OFLOW, 'd'}, -#endif - { TS_TBLOCK, 'K'}, - { TS_ASYNC, 'Y'}, - { TS_BKSL, 'D'}, - { TS_ERASE, 'E'}, - { TS_LNCH, 'L'}, - { TS_TYPEN, 'P'}, - { TS_CNTTB, 'N'}, -#ifdef TS_CAN_BYPASS_L_RINT - { TS_CAN_BYPASS_L_RINT, 'l'}, -#endif -#ifdef TS_SNOOP - { TS_SNOOP, 's'}, -#endif -#ifdef TS_ZOMBIE - { TS_ZOMBIE, 'Z'}, +#if 0 + { TF_NOPREFIX, 'N' }, #endif - { 0, '\0'}, + { TF_INITLOCK, 'I' }, + { TF_CALLOUT, 'C' }, + + /* Keep these together -> 'Oi' and 'Oo'. */ + { TF_OPENED, 'O' }, + { TF_OPENED_IN, 'i' }, + { TF_OPENED_OUT,'o' }, + + { TF_GONE, 'G' }, + { TF_OPENCLOSE, 'B' }, + { TF_ASYNC, 'Y' }, + { TF_LITERAL, 'L' }, + + /* Keep these together -> 'Hi' and 'Ho'. */ + { TF_HIWAT, 'H' }, + { TF_HIWAT_IN, 'i' }, + { TF_HIWAT_OUT, 'o' }, + + { TF_STOPPED, 'S' }, + { TF_EXCLUDE, 'X' }, + { TF_BYPASS, 'l' }, + { TF_ZOMBIE, 'Z' }, + + { 0, '\0' }, }; static void ttyprt(struct xtty *xt) { int i, j; - char *name, state[20]; + char *name; if (xt->xt_size != sizeof *xt) errx(1, "struct xtty size mismatch"); if (usenumflag || xt->xt_dev == 0 || (name = devname(xt->xt_dev, S_IFCHR)) == NULL) - printf(" %2d,%-2d", major(xt->xt_dev), minor(xt->xt_dev)); + printf("%5d,%4d ", major(xt->xt_dev), minor(xt->xt_dev)); else - (void)printf("%7s ", name); - (void)printf("%2ld %3ld ", xt->xt_rawcc, xt->xt_cancc); - (void)printf("%3ld %5d %5d %4d %3d %7d ", xt->xt_outcc, - xt->xt_ihiwat, xt->xt_ilowat, xt->xt_ohiwat, xt->xt_olowat, - xt->xt_column); + printf("%10s ", name); + printf("%5zu %4zu %4zu %4zu %5zu %4zu %4zu %5u %5d %5d ", + xt->xt_insize, xt->xt_incc, xt->xt_inlc, + (xt->xt_insize - xt->xt_inlow), xt->xt_outsize, + xt->xt_outcc, (xt->xt_outsize - xt->xt_outlow), + xt->xt_column, xt->xt_sid, xt->xt_pgid); for (i = j = 0; ttystates[i].flag; i++) - if (xt->xt_state & ttystates[i].flag) - state[j++] = ttystates[i].val; + if (xt->xt_flags & ttystates[i].flag) { + putchar(ttystates[i].val); + j++; + } if (j == 0) - state[j++] = '-'; - state[j] = '\0'; - (void)printf("%-6s %8d", state, xt->xt_sid); - (void)printf("%6d ", xt->xt_pgid); - switch (xt->xt_line) { - case TTYDISC: - (void)printf("term\n"); - break; - case SLIPDISC: - (void)printf("slip\n"); - break; - case PPPDISC: - (void)printf("ppp\n"); - break; - default: - (void)printf("%d\n", xt->xt_line); - break; - } + putchar('-'); + putchar('\n'); } static void |