added 'int f_nerr' for external routines. DLW
[unix-history] / usr / src / sys / kern / kern_synch.c
index 6e13ece..24e15f3 100644 (file)
@@ -1,4 +1,4 @@
-/*     kern_synch.c    3.13    %G%     */
+/*     kern_synch.c    4.7     %G%     */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -10,7 +10,7 @@
 #include "../h/vm.h"
 #include "../h/pte.h"
 #include "../h/inline.h"
 #include "../h/vm.h"
 #include "../h/pte.h"
 #include "../h/inline.h"
-
+#include "../h/mtpr.h"
 
 #define SQSIZE 0100    /* Must be power of 2 */
 #define HASH(x)        (( (int) x >> 5) & (SQSIZE-1))
 
 #define SQSIZE 0100    /* Must be power of 2 */
 #define HASH(x)        (( (int) x >> 5) & (SQSIZE-1))
@@ -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,16 +167,12 @@ 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)
+                               if(p->p_pri < curpri) {
                                        runrun++;
                                        runrun++;
+                                       aston();
+                               }
                                if(runout != 0 && (p->p_flag&SLOAD) == 0) {
                                        runout = 0;
                                        wakeup((caddr_t)&runout);
                                if(runout != 0 && (p->p_flag&SLOAD) == 0) {
                                        runout = 0;
                                        wakeup((caddr_t)&runout);
@@ -194,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.
@@ -206,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;
@@ -239,8 +229,10 @@ register struct proc *p;
        if (p->p_flag & SLOAD)
                setrq(p);
        splx(s);
        if (p->p_flag & SLOAD)
                setrq(p);
        splx(s);
-       if(p->p_pri < curpri)
+       if(p->p_pri < curpri) {
                runrun++;
                runrun++;
+               aston();
+       }
        if(runout != 0 && (p->p_flag&SLOAD) == 0) {
                runout = 0;
                wakeup((caddr_t)&runout);
        if(runout != 0 && (p->p_flag&SLOAD) == 0) {
                runout = 0;
                wakeup((caddr_t)&runout);
@@ -259,11 +251,13 @@ register struct proc *pp;
        register p;
 
        p = (pp->p_cpu & 0377)/16;
        register p;
 
        p = (pp->p_cpu & 0377)/16;
-       p += PUSER + pp->p_nice - NZERO;
+       p += PUSER + 2*(pp->p_nice - NZERO);
        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);
 }
@@ -308,7 +302,7 @@ retry:
        rip = u.u_procp;
        rpp->p_stat = SIDL;
        rpp->p_clktim = 0;
        rip = u.u_procp;
        rpp->p_stat = SIDL;
        rpp->p_clktim = 0;
-       rpp->p_flag = SLOAD | (rip->p_flag & (SPAGI|SDETACH));
+       rpp->p_flag = SLOAD | (rip->p_flag & (SPAGI|SDETACH|SNUSIG));
        if (isvfork) {
                rpp->p_flag |= SVFORK;
                rpp->p_ndx = rip->p_ndx;
        if (isvfork) {
                rpp->p_flag |= SVFORK;
                rpp->p_ndx = rip->p_ndx;
@@ -342,8 +336,8 @@ retry:
        rpp->p_rssize = 0;
        rpp->p_wchan = 0;
        rpp->p_slptime = 0;
        rpp->p_rssize = 0;
        rpp->p_wchan = 0;
        rpp->p_slptime = 0;
-       rpp->p_aveflt = rip->p_aveflt;
-       rpp->p_faults = 0;
+       rpp->p_pctcpu = 0;
+       rpp->p_cpticks = 0;
        n = PIDHASH(rpp->p_pid);
        p->p_idhash = pidhash[n];
        pidhash[n] = rpp - proc;
        n = PIDHASH(rpp->p_pid);
        p->p_idhash = pidhash[n];
        pidhash[n] = rpp - proc;
@@ -357,9 +351,17 @@ 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) {
-                       u.u_ofile[n]->f_count++;
-                       if(!isvfork && u.u_vrpages[n])
-                               u.u_ofile[n]->f_inode->i_vfdcnt++;
+#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_cdir->i_count++;
                }
 
        u.u_cdir->i_count++;
@@ -376,10 +378,10 @@ retry:
        if (procdup(rpp, isvfork))
                return (1);
 
        if (procdup(rpp, isvfork))
                return (1);
 
-       spl6();
+       (void) spl6();
        rpp->p_stat = SRUN;
        setrq(rpp);
        rpp->p_stat = SRUN;
        setrq(rpp);
-       spl0();
+       (void) spl0();
        /* SSWAP NOT NEEDED IN THIS CASE AS u.u_pcb.pcb_sswap SUFFICES */
        /* rpp->p_flag |= SSWAP; */
        rip->p_flag &= ~SKEEP;
        /* SSWAP NOT NEEDED IN THIS CASE AS u.u_pcb.pcb_sswap SUFFICES */
        /* rpp->p_flag |= SSWAP; */
        rip->p_flag &= ~SKEEP;