diff options
author | jeff <jeff@FreeBSD.org> | 2003-03-03 05:29:09 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2003-03-03 05:29:09 +0000 |
commit | 20fffd027438d4ff975fb9000f517bd854b44379 (patch) | |
tree | c8835521d304853bafd6b09903736d433d0d267b /sys/kern/sched_ule.c | |
parent | 1b88f49a56ff5f9a6b123f2f38905a2143eda881 (diff) | |
download | FreeBSD-src-20fffd027438d4ff975fb9000f517bd854b44379.zip FreeBSD-src-20fffd027438d4ff975fb9000f517bd854b44379.tar.gz |
- Shift the tick count by 10 and back around sched_pctcpu_update()
calculations. Keep this changes local to the function so the tick count
is in its natural form otherwise. Previously 1000 was added each time
a tick fired and we divided by 1000 when it was reported. This is done
to reduce rounding errors.
Diffstat (limited to 'sys/kern/sched_ule.c')
-rw-r--r-- | sys/kern/sched_ule.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 7de1c2e..6379608 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -418,8 +418,14 @@ sched_pctcpu_update(struct kse *ke) /* * Adjust counters and watermark for pctcpu calc. */ + /* + * Shift the tick count out so that the divide doesn't round away + * our results. + */ + ke->ke_ticks <<= 10; ke->ke_ticks = (ke->ke_ticks / (ke->ke_ltick - ke->ke_ftick)) * SCHED_CPU_TICKS; + ke->ke_ticks >>= 10; ke->ke_ltick = ticks; ke->ke_ftick = ke->ke_ltick - SCHED_CPU_TICKS; } @@ -665,7 +671,7 @@ sched_clock(struct thread *td) KASSERT((td != NULL), ("schedclock: null thread pointer")); /* Adjust ticks for pctcpu */ - ke->ke_ticks += 10000; + ke->ke_ticks++; ke->ke_ltick = ticks; /* Go up to one second beyond our max and then trim back down */ if (ke->ke_ftick + SCHED_CPU_TICKS + hz < ke->ke_ltick) @@ -865,7 +871,7 @@ sched_pctcpu(struct kse *ke) sched_pctcpu_update(ke); /* How many rtick per second ? */ - rtick = ke->ke_ticks / (SCHED_CPU_TIME * 10000); + rtick = ke->ke_ticks / SCHED_CPU_TIME; pctcpu = (FSCALE * ((FSCALE * rtick)/realstathz)) >> FSHIFT; } |