fix to computation of integral times in kern_clock and alarm(0) in _time
authorBill Joy <root@ucbvax.Berkeley.EDU>
Fri, 31 Dec 1982 08:28:21 +0000 (00:28 -0800)
committerBill Joy <root@ucbvax.Berkeley.EDU>
Fri, 31 Dec 1982 08:28:21 +0000 (00:28 -0800)
SCCS-vsn: sys/kern/kern_clock.c 4.49
SCCS-vsn: sys/kern/kern_time.c 5.14

usr/src/sys/kern/kern_clock.c
usr/src/sys/kern/kern_time.c

index 6769872..2491891 100644 (file)
@@ -1,4 +1,4 @@
-/*     kern_clock.c    4.48    82/12/17        */
+/*     kern_clock.c    4.49    82/12/30        */
 
 #include "../machine/reg.h"
 #include "../machine/psl.h"
 
 #include "../machine/reg.h"
 #include "../machine/psl.h"
@@ -95,37 +95,6 @@ hardclock(regs)
        if (p1)
                --p1->c_time;
 
        if (p1)
                --p1->c_time;
 
-       /*
-        * If the cpu is currently scheduled to a process, then
-        * charge it with resource utilization for a tick, updating
-        * statistics which run in (user+system) virtual time,
-        * such as the cpu time limit and profiling timers.
-        * This assumes that the current process has been running
-        * the entire last tick.
-        */
-       if (!noproc) {
-               s = u.u_procp->p_rssize;
-               u.u_ru.ru_idrss += s; u.u_ru.ru_isrss += 0;     /* XXX */
-               if (u.u_procp->p_textp) {
-                       register int xrss = u.u_procp->p_textp->x_rssize;
-
-                       s += xrss;
-                       u.u_ru.ru_ixrss += xrss;
-               }
-               if (s > u.u_ru.ru_maxrss)
-                       u.u_ru.ru_maxrss = s;
-               if ((u.u_ru.ru_utime.tv_sec+u.u_ru.ru_stime.tv_sec+1) >
-                   u.u_rlimit[RLIMIT_CPU].rlim_cur) {
-                       psignal(u.u_procp, SIGXCPU);
-                       if (u.u_rlimit[RLIMIT_CPU].rlim_cur <
-                           u.u_rlimit[RLIMIT_CPU].rlim_max)
-                               u.u_rlimit[RLIMIT_CPU].rlim_cur += 5;
-               }
-               if (timerisset(&u.u_timer[ITIMER_PROF].it_value) &&
-                   itimerdecr(&u.u_timer[ITIMER_PROF], tick) == 0)
-                       psignal(u.u_procp, SIGPROF);
-       }
-
        /*
         * Charge the time out based on the mode the cpu is in.
         * Here again we fudge for the lack of proper interval timers
        /*
         * Charge the time out based on the mode the cpu is in.
         * Here again we fudge for the lack of proper interval timers
@@ -146,6 +115,36 @@ hardclock(regs)
                        cpstate = CP_NICE;
                else
                        cpstate = CP_USER;
                        cpstate = CP_NICE;
                else
                        cpstate = CP_USER;
+               /*
+                * Charge it with resource utilization for a tick, updating
+                * statistics which run in (user+system) virtual time,
+                * such as the cpu time limit and profiling timers.
+                * This assumes that the current process has been running
+                * the entire last tick.
+                */
+               if (!noproc) {
+                       s = u.u_procp->p_rssize;
+                       u.u_ru.ru_idrss += s; u.u_ru.ru_isrss += 0;     /* XXX */
+                       if (u.u_procp->p_textp) {
+                               register int xrss = u.u_procp->p_textp->x_rssize;
+
+                               s += xrss;
+                               u.u_ru.ru_ixrss += xrss;
+                       }
+                       if (s > u.u_ru.ru_maxrss)
+                               u.u_ru.ru_maxrss = s;
+                       if ((u.u_ru.ru_utime.tv_sec+u.u_ru.ru_stime.tv_sec+1) >
+                           u.u_rlimit[RLIMIT_CPU].rlim_cur) {
+                               psignal(u.u_procp, SIGXCPU);
+                               if (u.u_rlimit[RLIMIT_CPU].rlim_cur <
+                                   u.u_rlimit[RLIMIT_CPU].rlim_max)
+                                       u.u_rlimit[RLIMIT_CPU].rlim_cur += 5;
+                       }
+                       if (timerisset(&u.u_timer[ITIMER_PROF].it_value) &&
+                           itimerdecr(&u.u_timer[ITIMER_PROF], tick) == 0)
+                               psignal(u.u_procp, SIGPROF);
+               }
+
        } else {
                /*
                 * CPU was in system state.  If profiling kernel
        } else {
                /*
                 * CPU was in system state.  If profiling kernel
index 1065e26..28607a7 100644 (file)
@@ -1,4 +1,4 @@
-/*     kern_time.c     5.13    82/12/28        */
+/*     kern_time.c     5.14    82/12/30        */
 
 #include "../machine/reg.h"
 
 
 #include "../machine/reg.h"
 
@@ -358,6 +358,7 @@ oalarm()
            timercmp(&p->p_realtimer.it_value, &time, >))
                u.u_r.r_val1 = p->p_realtimer.it_value.tv_sec - time.tv_sec;
        if (uap->deltat == 0) {
            timercmp(&p->p_realtimer.it_value, &time, >))
                u.u_r.r_val1 = p->p_realtimer.it_value.tv_sec - time.tv_sec;
        if (uap->deltat == 0) {
+               timerclear(&p->p_realtimer.it_value);
                splx(s);
                return;
        }
                splx(s);
                return;
        }