- 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;
+ if (p) {
+ if ((p->p_utime.tv_sec+p->p_stime.tv_sec+1) >
+ p->p_rlimit[RLIMIT_CPU].rlim_cur) {
+ psignal(p, SIGXCPU);
+ if (p->p_rlimit[RLIMIT_CPU].rlim_cur <
+ p->p_rlimit[RLIMIT_CPU].rlim_max)
+ p->p_rlimit[RLIMIT_CPU].rlim_cur += 5;
+ }
+ if (timerisset(&pstats->p_timer[ITIMER_PROF].it_value) &&
+ itimerdecr(&pstats->p_timer[ITIMER_PROF], tick) == 0)
+ psignal(p, SIGPROF);
+
+ /*
+ * We adjust the priority of the current process.
+ * The priority of a process gets worse as it accumulates
+ * CPU time. The cpu usage estimator (p_cpu) is increased here
+ * and the formula for computing priorities (in kern_synch.c)
+ * will compute a different value each time the p_cpu increases
+ * by 4. The cpu usage estimator ramps up quite quickly when
+ * the process is running (linearly), and decays away
+ * exponentially, * at a rate which is proportionally slower
+ * when the system is busy. The basic principal is that the
+ * system will 90% forget that a process used a lot of CPU
+ * time in 5*loadav seconds. This causes the system to favor
+ * processes which haven't run much recently, and to
+ * round-robin among other processes.
+ */
+ p->p_cpticks++;
+ if (++p->p_cpu == 0)
+ p->p_cpu--;
+ if ((p->p_cpu&3) == 0) {
+ setpri(p);
+ if (p->p_pri >= PUSER)
+ p->p_pri = p->p_usrpri;
+ }
+ }
+
+ /*
+ * If the alternate clock has not made itself known then
+ * we must gather the statistics.
+ */
+ if (phz == 0)
+ gatherstats(&frame);