summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_synch.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2002-07-14 03:43:33 +0000
committerjulian <julian@FreeBSD.org>2002-07-14 03:43:33 +0000
commitd84464f213f9ba21a322886ecef90d13e9d43b74 (patch)
treeaafccf41b7ab2599852d32b259154da2899a2107 /sys/kern/kern_synch.c
parent8dcca6c13311debeaa8c8fd0fee178622bc65cd9 (diff)
downloadFreeBSD-src-d84464f213f9ba21a322886ecef90d13e9d43b74.zip
FreeBSD-src-d84464f213f9ba21a322886ecef90d13e9d43b74.tar.gz
Thinking about it I came to the conclusion that the KSE states were incorrectly
formulated. The correct states should be: IDLE: On the idle KSE list for that KSEG RUNQ: Linked onto the system run queue. THREAD: Attached to a thread and slaved to whatever state the thread is in. This means that most places where we were adjusting kse state can go away as it is just moving around because the thread is.. The only places we need to adjust the KSE state is in transition to and from the idle and run queues. Reviewed by: jhb@freebsd.org
Diffstat (limited to 'sys/kern/kern_synch.c')
-rw-r--r--sys/kern/kern_synch.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index d376910..d07f090 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -282,8 +282,9 @@ schedcpu(arg)
* the kse slptimes are not touched in wakeup
* because the thread may not HAVE a KSE
*/
- if (ke->ke_state == KES_ONRUNQ ||
- ke->ke_state == KES_RUNNING) {
+ if ((ke->ke_state == KES_ONRUNQ) ||
+ ((ke->ke_state == KES_THREAD) &&
+ (ke->ke_thread->td_state == TDS_RUNNING))) {
ke->ke_slptime++;
} else {
ke->ke_slptime = 0;
@@ -442,8 +443,6 @@ msleep(ident, mtx, priority, wmesg, timo)
if (KTRPOINT(td, KTR_CSW))
ktrcsw(1, 0);
#endif
- KASSERT((td->td_kse != NULL), ("msleep: NULL KSE?"));
- KASSERT((td->td_kse->ke_state == KES_RUNNING), ("msleep: kse state?"));
WITNESS_SLEEP(0, &mtx->mtx_object);
KASSERT(timo != 0 || mtx_owned(&Giant) || mtx != NULL,
("sleeping without a mutex"));
@@ -470,19 +469,12 @@ msleep(ident, mtx, priority, wmesg, timo)
mtx_lock_spin(&sched_lock);
if (TAILQ_FIRST(&td->td_ksegrp->kg_runq) == NULL) {
/* Don't recurse here! */
- KASSERT((td->td_kse->ke_state == KES_RUNNING), ("msleep: kse stateX?"));
td->td_flags |= TDF_INMSLEEP;
thread_schedule_upcall(td, td->td_kse);
td->td_flags &= ~TDF_INMSLEEP;
- KASSERT((td->td_kse->ke_state == KES_RUNNING), ("msleep: kse stateY?"));
}
mtx_unlock_spin(&sched_lock);
}
- KASSERT((td->td_kse != NULL), ("msleep: NULL KSE2?"));
- KASSERT((td->td_kse->ke_state == KES_RUNNING),
- ("msleep: kse state2?"));
- KASSERT((td->td_kse->ke_thread == td),
- ("msleep: kse/thread mismatch?"));
}
mtx_lock_spin(&sched_lock);
if (cold || panicstr) {
@@ -797,7 +789,7 @@ mi_switch()
u_int sched_nest;
mtx_assert(&sched_lock, MA_OWNED | MA_NOTRECURSED);
- KASSERT((ke->ke_state == KES_RUNNING), ("mi_switch: kse state?"));
+ KASSERT((ke->ke_state == KES_THREAD), ("mi_switch: kse state?"));
#ifdef INVARIANTS
if (td->td_state != TDS_MTX &&
td->td_state != TDS_RUNQ &&
@@ -884,7 +876,6 @@ mi_switch()
}
cpu_switch();
td->td_kse->ke_oncpu = PCPU_GET(cpuid);
- td->td_kse->ke_state = KES_RUNNING;
sched_lock.mtx_recurse = sched_nest;
sched_lock.mtx_lock = (uintptr_t)td;
CTR3(KTR_PROC, "mi_switch: new thread %p (pid %d, %s)", td, p->p_pid,
OpenPOWER on IntegriCloud