Fixed the previous fix - stathz doesn't give the statclock frequency

when it is 0.

Submitted by:	mostly by Hidetoshi Shimokawa <simokawa@sat.t.u-tokyo.ac.jp>
This commit is contained in:
Bruce Evans 1998-11-26 16:49:55 +00:00
parent 44f05f9c92
commit e7414d1bfa
1 changed files with 6 additions and 5 deletions

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_synch.c 8.9 (Berkeley) 5/19/95
* $Id: kern_synch.c,v 1.66 1998/11/26 14:00:08 bde Exp $
* $Id: kern_synch.c,v 1.67 1998/11/26 14:05:58 bde Exp $
*/
#include "opt_ktrace.h"
@ -253,9 +253,10 @@ schedcpu(arg)
{
register fixpt_t loadfac = loadfactor(averunnable.ldavg[0]);
register struct proc *p;
register int s;
register int realstathz, s;
register unsigned int newcpu;
realstathz = stathz ? stathz : hz;
for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
/*
* Increment time in/out of memory and sleep time
@ -277,13 +278,13 @@ schedcpu(arg)
* p_pctcpu is only for ps.
*/
#if (FSHIFT >= CCPU_SHIFT)
p->p_pctcpu += (stathz == 100)?
p->p_pctcpu += (realstathz == 100)?
((fixpt_t) p->p_cpticks) << (FSHIFT - CCPU_SHIFT):
100 * (((fixpt_t) p->p_cpticks)
<< (FSHIFT - CCPU_SHIFT)) / stathz;
<< (FSHIFT - CCPU_SHIFT)) / realstathz;
#else
p->p_pctcpu += ((FSCALE - ccpu) *
(p->p_cpticks * FSCALE / stathz)) >> FSHIFT;
(p->p_cpticks * FSCALE / realstathz)) >> FSHIFT;
#endif
p->p_cpticks = 0;
newcpu = (u_int) decay_cpu(loadfac, p->p_estcpu) + p->p_nice;