summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2003-10-04 17:41:13 +0000
committerjeff <jeff@FreeBSD.org>2003-10-04 17:41:13 +0000
commit1fc48676923e2ae6881c21a44cff8df82d10fabb (patch)
treef69e1261b63d2992b4c9678abb033957c1200055 /sys
parent9d218b6014e7b99cbd4d663d059f1408e4ac20f7 (diff)
downloadFreeBSD-src-1fc48676923e2ae6881c21a44cff8df82d10fabb.zip
FreeBSD-src-1fc48676923e2ae6881c21a44cff8df82d10fabb.tar.gz
- Change a lame iterative algorithm to a constant time algorithm. Remove
the XXX that complains about it as well. Submitted by: ThomasWuerfl@gmx.de
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/sched_ule.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index cab763a..9fbfb0c 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -673,10 +673,12 @@ sched_slice(struct kse *ke)
static void
sched_interact_update(struct ksegrp *kg)
{
- /* XXX Fixme, use a linear algorithm and not a while loop. */
- while ((kg->kg_runtime + kg->kg_slptime) > SCHED_SLP_RUN_MAX) {
- kg->kg_runtime = (kg->kg_runtime / 5) * 4;
- kg->kg_slptime = (kg->kg_slptime / 5) * 4;
+ int ratio;
+ if ((kg->kg_runtime + kg->kg_slptime) > SCHED_SLP_RUN_MAX) {
+ ratio = (SCHED_SLP_RUN_MAX /
+ (kg->kg_runtime + kg->kg_slptime)) * 4;
+ kg->kg_runtime = (kg->kg_runtime * ratio) / 5;
+ kg->kg_slptime = (kg->kg_slptime * ratio) / 5;
}
}
OpenPOWER on IntegriCloud