diff options
author | jhb <jhb@FreeBSD.org> | 2001-02-20 05:26:15 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2001-02-20 05:26:15 +0000 |
commit | 27efeb0d3097def44db638ca1b56b51d59d27262 (patch) | |
tree | 1f8a102953b3fe1c9808c071ae97fe452a9e22c0 /sys/kern/kern_synch.c | |
parent | 186e24ad6b2494564362a9d8c0824ab7c38db682 (diff) | |
download | FreeBSD-src-27efeb0d3097def44db638ca1b56b51d59d27262.zip FreeBSD-src-27efeb0d3097def44db638ca1b56b51d59d27262.tar.gz |
- Don't call clear_resched() in userret(), instead, clear the resched flag
in mi_switch() just before calling cpu_switch() so that the first switch
after a resched request will satisfy the request.
- While I'm at it, move a few things into mi_switch() and out of
cpu_switch(), specifically set the p_oncpu and p_lastcpu members of
proc in mi_switch(), and handle the sched_lock state change across a
context switch in mi_switch().
- Since cpu_switch() no longer handles the sched_lock state change, we
have to setup an initial state for sched_lock in fork_exit() before we
release it.
Diffstat (limited to 'sys/kern/kern_synch.c')
-rw-r--r-- | sys/kern/kern_synch.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 694bdf1..1f21422 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -848,6 +848,7 @@ mi_switch() register struct rlimit *rlim; #endif int x; + u_int sched_nest; /* * XXX this spl is almost unnecessary. It is partly to allow for @@ -922,7 +923,14 @@ mi_switch() PCPU_SET(switchtime, new_switchtime); CTR4(KTR_PROC, "mi_switch: old proc %p (pid %d, %s), schedlock %p", p, p->p_pid, p->p_comm, (void *) sched_lock.mtx_lock); + sched_nest = sched_lock.mtx_recurse; + curproc->p_lastcpu = curproc->p_oncpu; + curproc->p_oncpu = NOCPU; + clear_resched(); cpu_switch(); + curproc->p_oncpu = PCPU_GET(cpuid); + sched_lock.mtx_recurse = sched_nest; + sched_lock.mtx_lock = curproc; CTR4(KTR_PROC, "mi_switch: new proc %p (pid %d, %s), schedlock %p", p, p->p_pid, p->p_comm, (void *) sched_lock.mtx_lock); if (PCPU_GET(switchtime.tv_sec) == 0) |