Deleted Added
full compact
sched_4bsd.c (109157) sched_4bsd.c (111032)
1/*-
2 * Copyright (c) 1982, 1986, 1990, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
1/*-
2 * Copyright (c) 1982, 1986, 1990, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * $FreeBSD: head/sys/kern/sched_4bsd.c 109157 2003-01-13 03:42:41Z jeff $
38 * $FreeBSD: head/sys/kern/sched_4bsd.c 111032 2003-02-17 09:55:10Z julian $
39 */
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/kernel.h>
44#include <sys/ktr.h>
45#include <sys/lock.h>
46#include <sys/mutex.h>

--- 71 unchanged lines hidden (view full) ---

118 * schedulers into account.
119 */
120static void
121maybe_resched(struct thread *td)
122{
123
124 mtx_assert(&sched_lock, MA_OWNED);
125 if (td->td_priority < curthread->td_priority && curthread->td_kse)
39 */
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/kernel.h>
44#include <sys/ktr.h>
45#include <sys/lock.h>
46#include <sys/mutex.h>

--- 71 unchanged lines hidden (view full) ---

118 * schedulers into account.
119 */
120static void
121maybe_resched(struct thread *td)
122{
123
124 mtx_assert(&sched_lock, MA_OWNED);
125 if (td->td_priority < curthread->td_priority && curthread->td_kse)
126 curthread->td_kse->ke_flags |= KEF_NEEDRESCHED;
126 curthread->td_flags |= TDF_NEEDRESCHED;
127}
128
129/*
130 * Force switch among equal priority processes every 100ms.
131 * We don't actually need to force a context switch of the current process.
132 * The act of firing the event triggers a context switch to softclock() and
133 * then switching back out again which is equivalent to a preemption, thus
134 * no further work is needed on the local CPU.

--- 395 unchanged lines hidden (view full) ---

530 ke = td->td_kse;
531 p = td->td_proc;
532
533 KASSERT((ke->ke_state == KES_THREAD), ("mi_switch: kse state?"));
534
535 td->td_lastcpu = ke->ke_oncpu;
536 td->td_last_kse = ke;
537 ke->ke_oncpu = NOCPU;
127}
128
129/*
130 * Force switch among equal priority processes every 100ms.
131 * We don't actually need to force a context switch of the current process.
132 * The act of firing the event triggers a context switch to softclock() and
133 * then switching back out again which is equivalent to a preemption, thus
134 * no further work is needed on the local CPU.

--- 395 unchanged lines hidden (view full) ---

530 ke = td->td_kse;
531 p = td->td_proc;
532
533 KASSERT((ke->ke_state == KES_THREAD), ("mi_switch: kse state?"));
534
535 td->td_lastcpu = ke->ke_oncpu;
536 td->td_last_kse = ke;
537 ke->ke_oncpu = NOCPU;
538 ke->ke_flags &= ~KEF_NEEDRESCHED;
538 td->td_flags &= ~TDF_NEEDRESCHED;
539 /*
540 * At the last moment, if this thread is still marked RUNNING,
541 * then put it back on the run queue as it has not been suspended
542 * or stopped or any thing else similar.
543 */
544 if (TD_IS_RUNNING(td)) {
545 /* Put us back on the run queue (kse and all). */
546 setrunqueue(td);

--- 123 unchanged lines hidden ---
539 /*
540 * At the last moment, if this thread is still marked RUNNING,
541 * then put it back on the run queue as it has not been suspended
542 * or stopped or any thing else similar.
543 */
544 if (TD_IS_RUNNING(td)) {
545 /* Put us back on the run queue (kse and all). */
546 setrunqueue(td);

--- 123 unchanged lines hidden ---