cleaned up and re-enable compaction
[unix-history] / usr / src / sys / kern / kern_resource.c
index f348846..e5cf063 100644 (file)
@@ -1,4 +1,4 @@
-/*     kern_resource.c 4.2     %G%     */
+/*     kern_resource.c 4.5     81/11/08        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -9,10 +9,11 @@
 #include "../h/proc.h"
 #include "../h/seg.h"
 
 #include "../h/proc.h"
 #include "../h/seg.h"
 
+struct inode *acctp;
+
 /*
  * Perform process accounting functions.
  */
 /*
  * Perform process accounting functions.
  */
-
 sysacct()
 {
        register struct inode *ip;
 sysacct()
 {
        register struct inode *ip;
@@ -23,9 +24,9 @@ sysacct()
        uap = (struct a *)u.u_ap;
        if (suser()) {
                if (uap->fname==NULL) {
        uap = (struct a *)u.u_ap;
        if (suser()) {
                if (uap->fname==NULL) {
-                       if (acctp) {
-                               plock(acctp);
-                               iput(acctp);
+                       if (ip = acctp) {
+                               ilock(ip);
+                               iput(ip);
                                acctp = NULL;
                        }
                        return;
                                acctp = NULL;
                        }
                        return;
@@ -43,10 +44,11 @@ sysacct()
                        return;
                }
                acctp = ip;
                        return;
                }
                acctp = ip;
-               prele(ip);
+               irele(ip);
        }
 }
 
        }
 }
 
+struct acct acctbuf;
 /*
  * On exit, write a record on the accounting file.
  */
 /*
  * On exit, write a record on the accounting file.
  */
@@ -55,34 +57,35 @@ acct()
        register i;
        register struct inode *ip;
        off_t siz;
        register i;
        register struct inode *ip;
        off_t siz;
+       register struct acct *ap = &acctbuf;
 
        if ((ip=acctp)==NULL)
                return;
 
        if ((ip=acctp)==NULL)
                return;
-       plock(ip);
-       for (i=0; i<sizeof(acctbuf.ac_comm); i++)
-               acctbuf.ac_comm[i] = u.u_comm[i];
-       acctbuf.ac_utime = compress((long)u.u_vm.vm_utime);
-       acctbuf.ac_stime = compress((long)u.u_vm.vm_stime);
-       acctbuf.ac_etime = compress((long)(time - u.u_start));
-       acctbuf.ac_btime = u.u_start;
-       acctbuf.ac_uid = u.u_ruid;
-       acctbuf.ac_gid = u.u_rgid;
-       acctbuf.ac_mem = 0;
+       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_vm.vm_utime);
+       ap->ac_stime = compress((long)u.u_vm.vm_stime);
+       ap->ac_etime = compress((long)(time - u.u_start));
+       ap->ac_btime = u.u_start;
+       ap->ac_uid = u.u_ruid;
+       ap->ac_gid = u.u_rgid;
+       ap->ac_mem = 0;
        if (i = u.u_vm.vm_utime + u.u_vm.vm_stime)
        if (i = u.u_vm.vm_utime + u.u_vm.vm_stime)
-               acctbuf.ac_mem = (u.u_vm.vm_ixrss + u.u_vm.vm_idsrss) / i;
-       acctbuf.ac_io = compress((long)(u.u_vm.vm_inblk + u.u_vm.vm_oublk));
-       acctbuf.ac_tty = u.u_ttyd;
-       acctbuf.ac_flag = u.u_acflag;
+               ap->ac_mem = (u.u_vm.vm_ixrss + u.u_vm.vm_idsrss) / i;
+       ap->ac_io = compress((long)(u.u_vm.vm_inblk + u.u_vm.vm_oublk));
+       ap->ac_tty = u.u_ttyd;
+       ap->ac_flag = u.u_acflag;
        siz = ip->i_size;
        u.u_offset = siz;
        siz = ip->i_size;
        u.u_offset = siz;
-       u.u_base = (caddr_t)&acctbuf;
+       u.u_base = (caddr_t)ap;
        u.u_count = sizeof(acctbuf);
        u.u_segflg = 1;
        u.u_error = 0;
        writei(ip);
        if(u.u_error)
                ip->i_size = siz;
        u.u_count = sizeof(acctbuf);
        u.u_segflg = 1;
        u.u_error = 0;
        writei(ip);
        if(u.u_error)
                ip->i_size = siz;
-       prele(ip);
+       irele(ip);
 }
 
 /*
 }
 
 /*
@@ -108,24 +111,3 @@ register long t;
        }
        return((exp<<13) + t);
 }
        }
        return((exp<<13) + t);
 }
-
-/*
- * lock user into core as much
- * as possible. swapping may still
- * occur if core grows.
- */
-syslock()
-{
-       register struct proc *p;
-       register struct a {
-               int     flag;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       if(suser()) {
-               p = u.u_procp;
-               p->p_flag &= ~SULOCK;
-               if(uap->flag)
-                       p->p_flag |= SULOCK;
-       }
-}