Deleted Added
full compact
sched_4bsd.c (131473) sched_4bsd.c (131481)
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.

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

28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35#include <sys/cdefs.h>
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.

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

28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sys/kern/sched_4bsd.c 131473 2004-07-02 19:09:50Z jhb $");
36__FBSDID("$FreeBSD: head/sys/kern/sched_4bsd.c 131481 2004-07-02 20:21:44Z jhb $");
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/kernel.h>
41#include <sys/ktr.h>
42#include <sys/lock.h>
43#include <sys/kthread.h>
44#include <sys/mutex.h>

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

649 KASSERT((ke->ke_state == KES_THREAD), ("sched_switch: kse state?"));
650
651 if ((p->p_flag & P_NOLOAD) == 0)
652 sched_tdcnt--;
653 if (newtd != NULL && (newtd->td_proc->p_flag & P_NOLOAD) == 0)
654 sched_tdcnt++;
655 td->td_lastcpu = td->td_oncpu;
656 td->td_last_kse = ke;
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/kernel.h>
41#include <sys/ktr.h>
42#include <sys/lock.h>
43#include <sys/kthread.h>
44#include <sys/mutex.h>

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

649 KASSERT((ke->ke_state == KES_THREAD), ("sched_switch: kse state?"));
650
651 if ((p->p_flag & P_NOLOAD) == 0)
652 sched_tdcnt--;
653 if (newtd != NULL && (newtd->td_proc->p_flag & P_NOLOAD) == 0)
654 sched_tdcnt++;
655 td->td_lastcpu = td->td_oncpu;
656 td->td_last_kse = ke;
657 td->td_flags &= ~TDF_NEEDRESCHED;
657 td->td_flags &= ~(TDF_NEEDRESCHED | TDF_OWEPREEMPT);
658 td->td_oncpu = NOCPU;
659 /*
660 * At the last moment, if this thread is still marked RUNNING,
661 * then put it back on the run queue as it has not been suspended
662 * or stopped or any thing else similar. We never put the idle
663 * threads on the run queue, however.
664 */
665 if (td == PCPU_GET(idlethread))

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

707 KASSERT((ke->ke_thread != NULL), ("sched_add: No thread on KSE"));
708 KASSERT((ke->ke_thread->td_kse != NULL),
709 ("sched_add: No KSE on thread"));
710 KASSERT(ke->ke_state != KES_ONRUNQ,
711 ("sched_add: kse %p (%s) already in run queue", ke,
712 ke->ke_proc->p_comm));
713 KASSERT(ke->ke_proc->p_sflag & PS_INMEM,
714 ("sched_add: process swapped out"));
658 td->td_oncpu = NOCPU;
659 /*
660 * At the last moment, if this thread is still marked RUNNING,
661 * then put it back on the run queue as it has not been suspended
662 * or stopped or any thing else similar. We never put the idle
663 * threads on the run queue, however.
664 */
665 if (td == PCPU_GET(idlethread))

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

707 KASSERT((ke->ke_thread != NULL), ("sched_add: No thread on KSE"));
708 KASSERT((ke->ke_thread->td_kse != NULL),
709 ("sched_add: No KSE on thread"));
710 KASSERT(ke->ke_state != KES_ONRUNQ,
711 ("sched_add: kse %p (%s) already in run queue", ke,
712 ke->ke_proc->p_comm));
713 KASSERT(ke->ke_proc->p_sflag & PS_INMEM,
714 ("sched_add: process swapped out"));
715
716#ifdef SMP
717 /*
718 * Only try to preempt if the thread is unpinned or pinned to the
719 * current CPU.
720 */
721 if (KSE_CAN_MIGRATE(ke) || ke->ke_runq == &runq_pcpu[PCPU_GET(cpuid)])
722#endif
723 if (maybe_preempt(td))
724 return;
715 ke->ke_ksegrp->kg_runq_kses++;
716 ke->ke_state = KES_ONRUNQ;
717
718#ifdef SMP
719 if (KSE_CAN_MIGRATE(ke)) {
720 CTR1(KTR_4BSD, "adding kse:%p to gbl runq", ke);
721 ke->ke_runq = &runq;
722 } else {

--- 166 unchanged lines hidden ---
725 ke->ke_ksegrp->kg_runq_kses++;
726 ke->ke_state = KES_ONRUNQ;
727
728#ifdef SMP
729 if (KSE_CAN_MIGRATE(ke)) {
730 CTR1(KTR_4BSD, "adding kse:%p to gbl runq", ke);
731 ke->ke_runq = &runq;
732 } else {

--- 166 unchanged lines hidden ---