aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2008-06-24 19:55:22 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2008-06-24 19:55:22 +0000
commit124c5b527e1bdb39510553668a20d2ab6526aadb (patch)
tree9a8dbec9ed2efc47ffa4cd20b3a38c9fcb55b5e4
parente59d82e875495b3d01c4804a5b432485faaae972 (diff)
Notes
-rw-r--r--sys/kern/sched_4bsd.c37
1 files changed, 8 insertions, 29 deletions
diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c
index 3733dec014de..aa5ea8d5c509 100644
--- a/sys/kern/sched_4bsd.c
+++ b/sys/kern/sched_4bsd.c
@@ -157,13 +157,10 @@ static int sched_tdcnt; /* Total runnable threads in the system. */
static int sched_quantum; /* Roundrobin scheduling quantum in ticks. */
#define SCHED_QUANTUM (hz / 10) /* Default sched quantum */
-static struct callout roundrobin_callout;
-
static void slot_fill(struct ksegrp *kg);
static struct kse *sched_choose(void); /* XXX Should be thread * */
static void setup_runqs(void);
-static void roundrobin(void *arg);
static void schedcpu(void);
static void schedcpu_thread(void);
static void sched_priority(struct thread *td, u_char prio);
@@ -316,27 +313,6 @@ maybe_resched(struct thread *td)
}
/*
- * Force switch among equal priority processes every 100ms.
- * We don't actually need to force a context switch of the current process.
- * The act of firing the event triggers a context switch to softclock() and
- * then switching back out again which is equivalent to a preemption, thus
- * no further work is needed on the local CPU.
- */
-/* ARGSUSED */
-static void
-roundrobin(void *arg)
-{
-
-#ifdef SMP
- mtx_lock_spin(&sched_lock);
- forward_roundrobin();
- mtx_unlock_spin(&sched_lock);
-#endif
-
- callout_reset(&roundrobin_callout, sched_quantum, roundrobin, NULL);
-}
-
-/*
* Constants for digital decay and forget:
* 90% of (kg_estcpu) usage in 5 * loadav time
* 95% of (ke_pctcpu) usage in 60 seconds (load insensitive)
@@ -618,11 +594,6 @@ sched_setup(void *dummy)
sched_quantum = SCHED_QUANTUM;
hogticks = 2 * sched_quantum;
- callout_init(&roundrobin_callout, CALLOUT_MPSAFE);
-
- /* Kick off timeout driven events by calling first time. */
- roundrobin(NULL);
-
/* Account for thread0. */
sched_load_add();
}
@@ -697,6 +668,14 @@ sched_clock(struct thread *td)
resetpriority(kg);
resetpriority_thread(td, kg);
}
+
+ /*
+ * Force a context switch if the current thread has used up a full
+ * quantum (default quantum is 100ms).
+ */
+ if (td != PCPU_GET(idlethread) &&
+ ticks - PCPU_GET(switchticks) >= sched_quantum)
+ td->td_flags |= TDF_NEEDRESCHED;
}
/*