profil returns
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Fri, 10 Dec 1982 15:46:17 +0000 (07:46 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Fri, 10 Dec 1982 15:46:17 +0000 (07:46 -0800)
SCCS-vsn: sys/vax/vax/locore.s 4.74
SCCS-vsn: sys/vax/vax/trap.c 4.25
SCCS-vsn: sys/kern/kern_clock.c 4.46

usr/src/sys/kern/kern_clock.c
usr/src/sys/vax/vax/locore.s
usr/src/sys/vax/vax/trap.c

index d795a92..4281dcb 100644 (file)
@@ -1,4 +1,4 @@
-/*     kern_clock.c    4.45    82/11/13        */
+/*     kern_clock.c    4.46    82/12/09        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -11,6 +11,9 @@
 #include "../h/psl.h"
 #include "../h/vm.h"
 #include "../h/text.h"
 #include "../h/psl.h"
 #include "../h/vm.h"
 #include "../h/text.h"
+#ifdef vax
+#include "../vax/mtpr.h"
+#endif
 #ifdef MUSH
 #include "../h/quota.h"
 #include "../h/share.h"
 #ifdef MUSH
 #include "../h/quota.h"
 #include "../h/share.h"
@@ -125,7 +128,7 @@ hardclock(regs)
                /*
                 * CPU was in user state.  Increment
                 * user time counter, and process process-virtual time
                /*
                 * CPU was in user state.  Increment
                 * user time counter, and process process-virtual time
-                * interval timer.
+                * interval timer. 
                 */
                bumptime(&u.u_ru.ru_utime, tick);
                if (timerisset(&u.u_timer[ITIMER_VIRTUAL].it_value) &&
                 */
                bumptime(&u.u_ru.ru_utime, tick);
                if (timerisset(&u.u_timer[ITIMER_VIRTUAL].it_value) &&
@@ -250,6 +253,13 @@ softclock(sirret, regs)
                splx(s);
                (*func)(arg, a);
        }
                splx(s);
                (*func)(arg, a);
        }
+       /*
+        * If trapped user-mode, give it a profiling tick.
+        */
+       if (USERMODE(ps) && u.u_prof.pr_scale) {
+               u.u_procp->p_flag |= SOWEUPC;
+               aston();
+       }
 }
 
 /*
 }
 
 /*
index 08311ce..110a1ce 100644 (file)
@@ -1,4 +1,4 @@
-/*     locore.s        4.73    82/11/03        */
+/*     locore.s        4.74    82/12/09        */
 
 #include "../vax/mtpr.h"
 #include "../vax/trap.h"
 
 #include "../vax/mtpr.h"
 #include "../vax/trap.h"
@@ -559,6 +559,31 @@ _badaddr:
        movab   2b,(sp)
        rei
 
        movab   2b,(sp)
        rei
 
+_addupc:       .globl  _addupc
+       .word   0x0
+       movl    8(ap),r2                # &u.u_prof
+       subl3   8(r2),4(ap),r0          # corrected pc
+       blss    9f
+       extzv   $1,$31,r0,r0            # logical right shift
+       extzv   $1,$31,12(r2),r1        # ditto for scale
+       emul    r1,r0,$0,r0
+       ashq    $-14,r0,r0
+       tstl    r1
+       bneq    9f
+       incl    r0
+       bicl2   $1,r0
+       cmpl    r0,4(r2)                # length
+       bgequ   9f
+       addl2   (r2),r0                 # base
+       probew  $3,$2,(r0)
+       beql    8f
+       addw2   12(ap),(r0)
+9:
+       ret
+8:
+       clrl    12(r2)
+       ret
+
 _Copyin:       .globl  _Copyin         # <<<massaged for jsb by asm.sed>>>
        movl    12(sp),r0               # copy length
        blss    ersb
 _Copyin:       .globl  _Copyin         # <<<massaged for jsb by asm.sed>>>
        movl    12(sp),r0               # copy length
        blss    ersb
index d236af1..09bfff0 100644 (file)
@@ -1,4 +1,4 @@
-/*     trap.c  4.24    82/11/13        */
+/*     trap.c  4.25    82/12/09        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -12,6 +12,7 @@
 #include "../h/psl.h"
 #include "../h/pte.h"
 #include "../h/acct.h"
 #include "../h/psl.h"
 #include "../h/pte.h"
 #include "../h/acct.h"
+#include "../h/kernel.h"
 #ifdef SYSCALLTRACE
 #include "../sys/syscalls.c"
 #endif
 #ifdef SYSCALLTRACE
 #include "../sys/syscalls.c"
 #endif
@@ -55,7 +56,9 @@ trap(sp, type, code, pc, psl)
        register int *locr0 = ((int *)&psl)-PS;
        register int i;
        register struct proc *p;
        register int *locr0 = ((int *)&psl)-PS;
        register int i;
        register struct proc *p;
+       struct timeval syst;
 
 
+       syst = u.u_ru.ru_stime;
        if (USERMODE(locr0[PS])) {
                type |= USER;
                u.u_ar0 = locr0;
        if (USERMODE(locr0[PS])) {
                type |= USER;
                u.u_ar0 = locr0;
@@ -82,6 +85,10 @@ trap(sp, type, code, pc, psl)
 
        case T_ASTFLT+USER:
                astoff();
 
        case T_ASTFLT+USER:
                astoff();
+               if ((u.u_procp->p_flag & SOWEUPC) && u.u_prof.pr_scale) {
+                       addupc(pc, &u.u_prof, 1);
+                       u.u_procp->p_flag &= ~SOWEUPC;
+               }
                goto out;
 
        case T_ARITHTRAP+USER:
                goto out;
 
        case T_ARITHTRAP+USER:
@@ -148,6 +155,15 @@ out:
                u.u_ru.ru_nivcsw++;
                swtch();
        }
                u.u_ru.ru_nivcsw++;
                swtch();
        }
+       if (u.u_prof.pr_scale) {
+               int ticks;
+               struct timeval *tv = &u.u_ru.ru_stime;
+
+               ticks = ((tv->tv_sec - syst.tv_sec) * 1000 +
+                       (tv->tv_usec - syst.tv_usec) / 1000) / (tick / 1000);
+               if (ticks)
+                       addupc(locr0[PC], &u.u_prof, ticks);
+       }
        curpri = p->p_pri;
 }
 
        curpri = p->p_pri;
 }
 
@@ -167,7 +183,9 @@ syscall(sp, type, code, pc, psl)
        register struct sysent *callp;
        register struct proc *p;
        int opc;
        register struct sysent *callp;
        register struct proc *p;
        int opc;
+       struct timeval syst;
 
 
+       syst = u.u_ru.ru_stime;
        if (!USERMODE(locr0[PS]))
                panic("syscall");
        u.u_ar0 = locr0;
        if (!USERMODE(locr0[PS]))
                panic("syscall");
        u.u_ar0 = locr0;
@@ -257,6 +275,15 @@ bad:
                u.u_ru.ru_nivcsw++;
                swtch();
        }
                u.u_ru.ru_nivcsw++;
                swtch();
        }
+       if (u.u_prof.pr_scale) {
+               int ticks;
+               struct timeval *tv = &u.u_ru.ru_stime;
+
+               ticks = ((tv->tv_sec - syst.tv_sec) * 1000 +
+                       (tv->tv_usec - syst.tv_usec) / 1000) / (tick / 1000);
+               if (ticks)
+                       addupc(locr0[PC], &u.u_prof, ticks);
+       }
        curpri = p->p_pri;
 }
 
        curpri = p->p_pri;
 }