if running over limit in tight core situation, lower priority
[unix-history] / usr / src / sys / kern / kern_synch.c
index 9b2a853..79f87ca 100644 (file)
@@ -1,4 +1,4 @@
-/*     kern_synch.c    4.5     %G%     */
+/*     kern_synch.c    4.12    81/04/15        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -55,10 +55,6 @@ caddr_t chan;
                        goto out;
                rp->p_stat = SSLEEP;
                (void) spl0();
                        goto out;
                rp->p_stat = SSLEEP;
                (void) spl0();
-               if(runin != 0) {
-                       runin = 0;
-                       wakeup((caddr_t)&runin);
-               }
                swtch();
                if(ISSIG(rp))
                        goto psig;
                swtch();
                if(ISSIG(rp))
                        goto psig;
@@ -171,14 +167,8 @@ restart:
                        if (p->p_stat == SSLEEP) {
                                /* OPTIMIZED INLINE EXPANSION OF setrun(p) */
                                p->p_stat = SRUN;
                        if (p->p_stat == SSLEEP) {
                                /* OPTIMIZED INLINE EXPANSION OF setrun(p) */
                                p->p_stat = SRUN;
-                               if (p->p_flag & SLOAD) {
-#ifndef FASTVAX
-                                       p->p_link = runq;
-                                       runq = p->p_link;
-#else
+                               if (p->p_flag & SLOAD)
                                        setrq(p);
                                        setrq(p);
-#endif
-                               }
                                if(p->p_pri < curpri) {
                                        runrun++;
                                        aston();
                                if(p->p_pri < curpri) {
                                        runrun++;
                                        aston();
@@ -196,7 +186,6 @@ restart:
        splx(s);
 }
 
        splx(s);
 }
 
-#ifdef FASTVAX
 /*
  * Initialize the (doubly-linked) run queues
  * to be empty.
 /*
  * Initialize the (doubly-linked) run queues
  * to be empty.
@@ -208,7 +197,6 @@ rqinit()
        for (i = 0; i < NQS; i++)
                qs[i].ph_link = qs[i].ph_rlink = (struct proc *)&qs[i];
 }
        for (i = 0; i < NQS; i++)
                qs[i].ph_link = qs[i].ph_rlink = (struct proc *)&qs[i];
 }
-#endif
 
 /*
  * Set the process running;
 
 /*
  * Set the process running;
@@ -264,10 +252,14 @@ register struct proc *pp;
 
        p = (pp->p_cpu & 0377)/16;
        p += PUSER + 2*(pp->p_nice - NZERO);
 
        p = (pp->p_cpu & 0377)/16;
        p += PUSER + 2*(pp->p_nice - NZERO);
+       if (pp->p_rssize > pp->p_maxrss && freemem < desfree)
+               p += 2*4;       /* effectively, nice(4) */
        if(p > 127)
                p = 127;
        if(p > 127)
                p = 127;
-       if(p < curpri)
+       if(p < curpri) {
                runrun++;
                runrun++;
+               aston();
+       }
        pp->p_usrpri = p;
        return(p);
 }
        pp->p_usrpri = p;
        return(p);
 }
@@ -296,7 +288,7 @@ retry:
                mpid = 0;
                goto retry;
        }
                mpid = 0;
                goto retry;
        }
-       for(rpp = &proc[0]; rpp < &proc[NPROC]; rpp++) {
+       for(rpp = proc; rpp < procNPROC; rpp++) {
                if(rpp->p_stat == NULL && p==NULL)
                        p = rpp;
                if (rpp->p_pid==mpid || rpp->p_pgrp==mpid)
                if(rpp->p_stat == NULL && p==NULL)
                        p = rpp;
                if (rpp->p_pid==mpid || rpp->p_pgrp==mpid)
@@ -344,6 +336,7 @@ retry:
                forkstat.sizfork += rip->p_dsize + rip->p_ssize;
        }
        rpp->p_rssize = 0;
                forkstat.sizfork += rip->p_dsize + rip->p_ssize;
        }
        rpp->p_rssize = 0;
+       rpp->p_maxrss = rip->p_maxrss;
        rpp->p_wchan = 0;
        rpp->p_slptime = 0;
        rpp->p_pctcpu = 0;
        rpp->p_wchan = 0;
        rpp->p_slptime = 0;
        rpp->p_pctcpu = 0;
@@ -361,17 +354,9 @@ retry:
 
        for(n=0; n<NOFILE; n++)
                if(u.u_ofile[n] != NULL) {
 
        for(n=0; n<NOFILE; n++)
                if(u.u_ofile[n] != NULL) {
-#ifdef UCBIPC
-                       if (u.u_pofile[n] & ISPORT)
-                               u.u_oport[n]->pt_count++;
-                       else {
-#endif
-                               u.u_ofile[n]->f_count++;
-                               if(!isvfork && u.u_vrpages[n])
-                                       u.u_ofile[n]->f_inode->i_vfdcnt++;
-#ifdef UCBIPC
-                       }
-#endif UCBIPC
+                       u.u_ofile[n]->f_count++;
+                       if(!isvfork && u.u_vrpages[n])
+                               u.u_ofile[n]->f_inode->i_vfdcnt++;
                }
 
        u.u_cdir->i_count++;
                }
 
        u.u_cdir->i_count++;