alloc tables at boot time version
[unix-history] / usr / src / sys / kern / kern_synch.c
index 2b1ea13..b7c6516 100644 (file)
@@ -1,4 +1,4 @@
-/*     kern_synch.c    3.9     %H%     */
+/*     kern_synch.c    4.8     %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))
@@ -31,7 +31,7 @@ sleep(chan, pri)
 caddr_t chan;
 {
        register struct proc *rp, **hp;
 caddr_t chan;
 {
        register struct proc *rp, **hp;
-       register s, h;
+       register s;
 
        rp = u.u_procp;
        s = spl6();
 
        rp = u.u_procp;
        s = spl6();
@@ -55,14 +55,11 @@ 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;
        } else {
                swtch();
                if(ISSIG(rp))
                        goto psig;
        } else {
+               rp->p_stat = SSLEEP;
                (void) spl0();
                swtch();
        }
                (void) spl0();
                swtch();
        }
@@ -163,23 +160,19 @@ restart:
        for (q = h; p = *q; ) {
                if (p->p_rlink || p->p_stat != SSLEEP && p->p_stat != SSTOP)
                        panic("wakeup");
        for (q = h; p = *q; ) {
                if (p->p_rlink || p->p_stat != SSLEEP && p->p_stat != SSTOP)
                        panic("wakeup");
-               if (p->p_wchan==chan && p->p_stat!=SZOMB) {
+               if (p->p_wchan==chan) {
                        p->p_wchan = 0;
                        *q = p->p_link;
                        p->p_slptime = 0;
                        if (p->p_stat == SSLEEP) {
                                /* OPTIMIZED INLINE EXPANSION OF setrun(p) */
                                p->p_stat = SRUN;
                        p->p_wchan = 0;
                        *q = p->p_link;
                        p->p_slptime = 0;
                        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);
@@ -193,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.
@@ -205,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;
@@ -214,7 +205,6 @@ rqinit()
 setrun(p)
 register struct proc *p;
 {
 setrun(p)
 register struct proc *p;
 {
-       register caddr_t w;
        register s;
 
        s = spl6();
        register s;
 
        s = spl6();
@@ -227,20 +217,22 @@ register struct proc *p;
        default:
                panic("setrun");
 
        default:
                panic("setrun");
 
+       case SSTOP:
        case SSLEEP:
                unsleep(p);             /* e.g. when sending signals */
                break;
 
        case SIDL:
        case SSLEEP:
                unsleep(p);             /* e.g. when sending signals */
                break;
 
        case SIDL:
-       case SSTOP:
                break;
        }
        p->p_stat = SRUN;
        if (p->p_flag & SLOAD)
                setrq(p);
        splx(s);
                break;
        }
        p->p_stat = SRUN;
        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);
 }
@@ -292,7 +286,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)
@@ -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);
+       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,9 +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;
-       rate.v_pgin += 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;
@@ -358,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++;
@@ -377,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;