summaryrefslogtreecommitdiffstats
path: root/sys/kern/sched_4bsd.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2004-09-16 07:12:59 +0000
committerjulian <julian@FreeBSD.org>2004-09-16 07:12:59 +0000
commit6461286b213d045e058cd62bba53b08477d34e1f (patch)
treed07e704218909383fd325c02883dbc86dfaeb565 /sys/kern/sched_4bsd.c
parent3d3172e3cda61cc88a5040098d4bf5cae6f93d77 (diff)
downloadFreeBSD-src-6461286b213d045e058cd62bba53b08477d34e1f.zip
FreeBSD-src-6461286b213d045e058cd62bba53b08477d34e1f.tar.gz
clean up thread runq accounting a bit.
MFC after: 3 days
Diffstat (limited to 'sys/kern/sched_4bsd.c')
-rw-r--r--sys/kern/sched_4bsd.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c
index 02c8f3c..a88e266 100644
--- a/sys/kern/sched_4bsd.c
+++ b/sys/kern/sched_4bsd.c
@@ -792,6 +792,12 @@ sched_switch(struct thread *td, struct thread *newtd, int flags)
/*
* The thread we are about to run needs to be counted as if it had been
* added to the run queue and selected.
+ * it came from:
+ * A preemption
+ * An upcall
+ * A followon
+ * Do this before saving curthread so that the slot count
+ * doesn't give an overly optimistic view when that happens.
*/
if (newtd) {
KASSERT((newtd->td_inhibitors == 0),
@@ -1024,6 +1030,7 @@ sched_add(struct thread *td, int flags)
}
if ((td->td_proc->p_flag & P_NOLOAD) == 0)
sched_tdcnt++;
+ td->td_ksegrp->kg_avail_opennings--;
runq_add(ke->ke_runq, ke);
ke->ke_ksegrp->kg_runq_kses++;
ke->ke_state = KES_ONRUNQ;
@@ -1044,12 +1051,17 @@ sched_rem(struct thread *td)
if ((td->td_proc->p_flag & P_NOLOAD) == 0)
sched_tdcnt--;
+ td->td_ksegrp->kg_avail_opennings++;
runq_remove(ke->ke_runq, ke);
ke->ke_state = KES_THREAD;
- ke->ke_ksegrp->kg_runq_kses--;
+ td->td_ksegrp->kg_runq_kses--;
}
+/*
+ * Select threads to run.
+ * Notice that the running threads still consume a slot.
+ */
struct kse *
sched_choose(void)
{
OpenPOWER on IntegriCloud