Deleted Added
full compact
kern_switch.c (99942) kern_switch.c (100209)
1/*
2 * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*
2 * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/kern/kern_switch.c 99942 2002-07-14 03:43:33Z julian $
26 * $FreeBSD: head/sys/kern/kern_switch.c 100209 2002-07-17 02:23:44Z gallatin $
27 */
28
29/***
30
31Here is the logic..
32
33If there are N processors, then there are at most N KSEs (kernel
34schedulable entities) working to process threads that belong to a

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

119 */
120struct thread *
121choosethread(void)
122{
123 struct kse *ke;
124 struct thread *td;
125 struct ksegrp *kg;
126
27 */
28
29/***
30
31Here is the logic..
32
33If there are N processors, then there are at most N KSEs (kernel
34schedulable entities) working to process threads that belong to a

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

119 */
120struct thread *
121choosethread(void)
122{
123 struct kse *ke;
124 struct thread *td;
125 struct ksegrp *kg;
126
127retry:
127 if ((ke = runq_choose(&runq))) {
128 td = ke->ke_thread;
129 KASSERT((td->td_kse == ke), ("kse/thread mismatch"));
130 kg = ke->ke_ksegrp;
131 if (td->td_flags & TDF_UNBOUND) {
132 TAILQ_REMOVE(&kg->kg_runq, td, td_runq);
133 if (kg->kg_last_assigned == td)
134 if (TAILQ_PREV(td, threadqueue, td_runq)

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

152 kg->kg_runnable--;
153 CTR2(KTR_RUNQ, "choosethread: td=%p pri=%d",
154 td, td->td_priority);
155 } else {
156 /* Simulate runq_choose() having returned the idle thread */
157 td = PCPU_GET(idlethread);
158 CTR1(KTR_RUNQ, "choosethread: td=%p (idle)", td);
159 }
128 if ((ke = runq_choose(&runq))) {
129 td = ke->ke_thread;
130 KASSERT((td->td_kse == ke), ("kse/thread mismatch"));
131 kg = ke->ke_ksegrp;
132 if (td->td_flags & TDF_UNBOUND) {
133 TAILQ_REMOVE(&kg->kg_runq, td, td_runq);
134 if (kg->kg_last_assigned == td)
135 if (TAILQ_PREV(td, threadqueue, td_runq)

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

153 kg->kg_runnable--;
154 CTR2(KTR_RUNQ, "choosethread: td=%p pri=%d",
155 td, td->td_priority);
156 } else {
157 /* Simulate runq_choose() having returned the idle thread */
158 td = PCPU_GET(idlethread);
159 CTR1(KTR_RUNQ, "choosethread: td=%p (idle)", td);
160 }
161 if (panicstr && ((td->td_proc->p_flag & P_SYSTEM) == 0 &&
162 (td->td_flags & TDF_INPANIC) == 0))
163 goto retry;
160 td->td_state = TDS_RUNNING;
161 return (td);
162}
163
164/*
165 * Given a KSE (now surplus), either assign a new runable thread to it
166 * (and put it in the run queue) or put it in the ksegrp's idle KSE list.
167 * Assumes the kse is not linked to any threads any more. (has been cleaned).

--- 554 unchanged lines hidden ---
164 td->td_state = TDS_RUNNING;
165 return (td);
166}
167
168/*
169 * Given a KSE (now surplus), either assign a new runable thread to it
170 * (and put it in the run queue) or put it in the ksegrp's idle KSE list.
171 * Assumes the kse is not linked to any threads any more. (has been cleaned).

--- 554 unchanged lines hidden ---