summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
5119bdf)
calculate average memory usage correctly (and returned in units of the
software page size so that sa can use getpagesize to figure out kilobytes)
SCCS-vsn: sys/kern/kern_acct.c 6.3
-/* kern_acct.c 6.2 84/07/08 */
+/* kern_acct.c 6.3 84/07/14 */
#include "../h/param.h"
#include "../h/systm.h"
#include "../h/param.h"
#include "../h/systm.h"
register int i;
register struct inode *ip;
register struct fs *fs;
register int i;
register struct inode *ip;
register struct fs *fs;
+ register struct rusage *ru;
register struct acct *ap = &acctbuf;
if (savacctp) {
register struct acct *ap = &acctbuf;
if (savacctp) {
ilock(ip);
for (i = 0; i < sizeof (ap->ac_comm); i++)
ap->ac_comm[i] = u.u_comm[i];
ilock(ip);
for (i = 0; i < sizeof (ap->ac_comm); i++)
ap->ac_comm[i] = u.u_comm[i];
- ap->ac_utime = compress((long)u.u_ru.ru_utime.tv_sec);
- ap->ac_stime = compress((long)u.u_ru.ru_stime.tv_sec);
- ap->ac_etime = compress((long)time.tv_sec - u.u_start);
- ap->ac_btime = u.u_start;
+ ru = &u.u_ru;
+ ap->ac_utime = compress(ru->ru_utime.tv_sec, ru->ru_utime.tv_usec);
+ ap->ac_stime = compress(ru->ru_stime.tv_sec, ru->ru_stime.tv_usec);
+ t = time;
+ timevalsub(&t, &u.u_start);
+ ap->ac_etime = compress(t.tv_sec, t.tv_usec);
+ ap->ac_btime = u.u_start.tv_sec;
ap->ac_uid = u.u_ruid;
ap->ac_gid = u.u_rgid;
ap->ac_uid = u.u_ruid;
ap->ac_gid = u.u_rgid;
- ap->ac_mem = 0;
- if (i = u.u_ru.ru_utime.tv_sec + u.u_ru.ru_stime.tv_sec)
- ap->ac_mem =
- (u.u_ru.ru_ixrss + u.u_ru.ru_idrss + u.u_ru.ru_isrss) / i;
- ap->ac_io = compress((long)(u.u_ru.ru_inblock + u.u_ru.ru_oublock));
+ t = ru->ru_stime;
+ timevaladd(&t, &ru->ru_utime);
+ if (i = t.tv_sec / hz + t.tv_usec / tick)
+ ap->ac_mem = (ru->ru_ixrss+ru->ru_idrss+ru->ru_isrss) / i;
+ else
+ ap->ac_mem = 0;
+ ap->ac_mem >>= CLSIZELOG2;
+ ap->ac_io = compress(ru->ru_inblock + ru->ru_oublock, 0);
if (u.u_ttyp)
ap->ac_tty = u.u_ttyd;
else
if (u.u_ttyp)
ap->ac_tty = u.u_ttyd;
else
* Produce a pseudo-floating point representation
* with 3 bits base-8 exponent, 13 bits fraction.
*/
* Produce a pseudo-floating point representation
* with 3 bits base-8 exponent, 13 bits fraction.
*/
{
register exp = 0, round = 0;
{
register exp = 0, round = 0;
+ t <<= 6;
+ if (ut)
+ t += ut / (1000000 / (1<<6));
while (t >= 8192) {
exp++;
round = t&04;
while (t >= 8192) {
exp++;
round = t&04;