diff options
author | dt <dt@FreeBSD.org> | 1999-05-22 20:10:31 +0000 |
---|---|---|
committer | dt <dt@FreeBSD.org> | 1999-05-22 20:10:31 +0000 |
commit | 20219ea96694d6163d1e5902345c310431619911 (patch) | |
tree | 107f0494cf8712359adaea1f114d354a923899f5 /sys | |
parent | 1dea181fa6ac7bb1b60556443d481ad036416953 (diff) | |
download | FreeBSD-src-20219ea96694d6163d1e5902345c310431619911.zip FreeBSD-src-20219ea96694d6163d1e5902345c310431619911.tar.gz |
Don't call calcru() on a swapped-out process. calcru() access p_stats, which
is in U-area.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/fs/procfs/procfs_status.c | 26 | ||||
-rw-r--r-- | sys/kern/tty.c | 19 | ||||
-rw-r--r-- | sys/miscfs/procfs/procfs_status.c | 26 |
3 files changed, 31 insertions, 40 deletions
diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c index ba1abe4..d34e215 100644 --- a/sys/fs/procfs/procfs_status.c +++ b/sys/fs/procfs/procfs_status.c @@ -37,7 +37,7 @@ * @(#)procfs_status.c 8.4 (Berkeley) 6/15/94 * * From: - * $Id: procfs_status.c,v 1.12 1999/01/05 03:53:06 peter Exp $ + * $Id: procfs_status.c,v 1.13 1999/04/28 11:37:20 phk Exp $ */ #include <sys/param.h> @@ -102,23 +102,17 @@ procfs_dostatus(curp, p, pfs, uio) if (*sep != ',') ps += sprintf(ps, "noflags"); - if (p->p_flag & P_INMEM) - ps += sprintf(ps, " %ld,%ld", - p->p_stats->p_start.tv_sec, - p->p_stats->p_start.tv_usec); - else - ps += sprintf(ps, " -1,-1"); - - { + if (p->p_flag & P_INMEM) { struct timeval ut, st; - calcru(p, &ut, &st, (void *) 0); - ps += sprintf(ps, " %ld,%ld %ld,%ld", - ut.tv_sec, - ut.tv_usec, - st.tv_sec, - st.tv_usec); - } + calcru(p, &ut, &st, (struct timeval *) NULL); + ps += sprintf(ps, " %ld,%ld %ld,%ld %ld,%ld", + p->p_stats->p_start.tv_sec, + p->p_stats->p_start.tv_usec, + ut.tv_sec, ut.tv_usec, + st.tv_sec, st.tv_usec); + } else + ps += sprintf(ps, " -1,-1 -1,-1 -1,-1"); ps += sprintf(ps, " %s", (p->p_wchan && p->p_wmesg) ? p->p_wmesg : "nochan"); diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 8b946cf..e9de97b 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)tty.c 8.8 (Berkeley) 1/21/94 - * $Id: tty.c,v 1.117 1999/05/06 18:12:47 peter Exp $ + * $Id: tty.c,v 1.118 1999/05/08 06:39:42 phk Exp $ */ /*- @@ -2260,15 +2260,18 @@ ttyinfo(tp) pick->p_stat == SRUN ? "running" : pick->p_wmesg ? pick->p_wmesg : "iowait"); - calcru(pick, &utime, &stime, NULL); + if (pick->p_flag & P_INMEM) { + calcru(pick, &utime, &stime, NULL); - /* Print user time. */ - ttyprintf(tp, "%ld.%02ldu ", - utime.tv_sec, utime.tv_usec / 10000); + /* Print user time. */ + ttyprintf(tp, "%ld.%02ldu ", + utime.tv_sec, utime.tv_usec / 10000); - /* Print system time. */ - ttyprintf(tp, "%ld.%02lds ", - stime.tv_sec, stime.tv_usec / 10000); + /* Print system time. */ + ttyprintf(tp, "%ld.%02lds ", + stime.tv_sec, stime.tv_usec / 10000); + } else + ttyprintf(tp, "?.??u ?.??s "); /* Print percentage cpu, resident set size. */ tmp = (pick->p_pctcpu * 10000 + FSCALE / 2) >> FSHIFT; diff --git a/sys/miscfs/procfs/procfs_status.c b/sys/miscfs/procfs/procfs_status.c index ba1abe4..d34e215 100644 --- a/sys/miscfs/procfs/procfs_status.c +++ b/sys/miscfs/procfs/procfs_status.c @@ -37,7 +37,7 @@ * @(#)procfs_status.c 8.4 (Berkeley) 6/15/94 * * From: - * $Id: procfs_status.c,v 1.12 1999/01/05 03:53:06 peter Exp $ + * $Id: procfs_status.c,v 1.13 1999/04/28 11:37:20 phk Exp $ */ #include <sys/param.h> @@ -102,23 +102,17 @@ procfs_dostatus(curp, p, pfs, uio) if (*sep != ',') ps += sprintf(ps, "noflags"); - if (p->p_flag & P_INMEM) - ps += sprintf(ps, " %ld,%ld", - p->p_stats->p_start.tv_sec, - p->p_stats->p_start.tv_usec); - else - ps += sprintf(ps, " -1,-1"); - - { + if (p->p_flag & P_INMEM) { struct timeval ut, st; - calcru(p, &ut, &st, (void *) 0); - ps += sprintf(ps, " %ld,%ld %ld,%ld", - ut.tv_sec, - ut.tv_usec, - st.tv_sec, - st.tv_usec); - } + calcru(p, &ut, &st, (struct timeval *) NULL); + ps += sprintf(ps, " %ld,%ld %ld,%ld %ld,%ld", + p->p_stats->p_start.tv_sec, + p->p_stats->p_start.tv_usec, + ut.tv_sec, ut.tv_usec, + st.tv_sec, st.tv_usec); + } else + ps += sprintf(ps, " -1,-1 -1,-1 -1,-1"); ps += sprintf(ps, " %s", (p->p_wchan && p->p_wmesg) ? p->p_wmesg : "nochan"); |