sched_4bsd.c (173364) | sched_4bsd.c (173600) |
---|---|
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 173364 2007-11-05 12:01:12Z rwatson $"); | 36__FBSDID("$FreeBSD: head/sys/kern/sched_4bsd.c 173600 2007-11-14 06:21:24Z julian $"); |
37 38#include "opt_hwpmc_hooks.h" 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/kernel.h> 43#include <sys/ktr.h> 44#include <sys/lock.h> --- 565 unchanged lines hidden (view full) --- 610/* 611 * charge childs scheduling cpu usage to parent. 612 */ 613void 614sched_exit(struct proc *p, struct thread *td) 615{ 616 617 CTR3(KTR_SCHED, "sched_exit: %p(%s) prio %d", | 37 38#include "opt_hwpmc_hooks.h" 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/kernel.h> 43#include <sys/ktr.h> 44#include <sys/lock.h> --- 565 unchanged lines hidden (view full) --- 610/* 611 * charge childs scheduling cpu usage to parent. 612 */ 613void 614sched_exit(struct proc *p, struct thread *td) 615{ 616 617 CTR3(KTR_SCHED, "sched_exit: %p(%s) prio %d", |
618 td, td->td_proc->p_comm, td->td_priority); | 618 td, td->td_name, td->td_priority); |
619 PROC_SLOCK_ASSERT(p, MA_OWNED); 620 sched_exit_thread(FIRST_THREAD_IN_PROC(p), td); 621} 622 623void 624sched_exit_thread(struct thread *td, struct thread *child) 625{ 626 627 CTR3(KTR_SCHED, "sched_exit_thread: %p(%s) prio %d", | 619 PROC_SLOCK_ASSERT(p, MA_OWNED); 620 sched_exit_thread(FIRST_THREAD_IN_PROC(p), td); 621} 622 623void 624sched_exit_thread(struct thread *td, struct thread *child) 625{ 626 627 CTR3(KTR_SCHED, "sched_exit_thread: %p(%s) prio %d", |
628 child, child->td_proc->p_comm, child->td_priority); | 628 child, child->td_name, child->td_priority); |
629 thread_lock(td); 630 td->td_estcpu = ESTCPULIM(td->td_estcpu + child->td_estcpu); 631 thread_unlock(td); 632 mtx_lock_spin(&sched_lock); 633 if ((child->td_proc->p_flag & P_NOLOAD) == 0) 634 sched_load_rem(); 635 mtx_unlock_spin(&sched_lock); 636} --- 37 unchanged lines hidden (view full) --- 674 675/* 676 * Adjust the priority of a thread. 677 */ 678static void 679sched_priority(struct thread *td, u_char prio) 680{ 681 CTR6(KTR_SCHED, "sched_prio: %p(%s) prio %d newprio %d by %p(%s)", | 629 thread_lock(td); 630 td->td_estcpu = ESTCPULIM(td->td_estcpu + child->td_estcpu); 631 thread_unlock(td); 632 mtx_lock_spin(&sched_lock); 633 if ((child->td_proc->p_flag & P_NOLOAD) == 0) 634 sched_load_rem(); 635 mtx_unlock_spin(&sched_lock); 636} --- 37 unchanged lines hidden (view full) --- 674 675/* 676 * Adjust the priority of a thread. 677 */ 678static void 679sched_priority(struct thread *td, u_char prio) 680{ 681 CTR6(KTR_SCHED, "sched_prio: %p(%s) prio %d newprio %d by %p(%s)", |
682 td, td->td_proc->p_comm, td->td_priority, prio, curthread, 683 curthread->td_proc->p_comm); | 682 td, td->td_name, td->td_priority, prio, curthread, 683 curthread->td_name); |
684 685 THREAD_LOCK_ASSERT(td, MA_OWNED); 686 if (td->td_priority == prio) 687 return; 688 td->td_priority = prio; 689 if (TD_ON_RUNQ(td) && 690 td->td_sched->ts_rqindex != (prio / RQ_PPQ)) { 691 sched_rem(td); --- 374 unchanged lines hidden (view full) --- 1066 THREAD_LOCK_ASSERT(td, MA_OWNED); 1067 KASSERT((td->td_inhibitors == 0), 1068 ("sched_add: trying to run inhibited thread")); 1069 KASSERT((TD_CAN_RUN(td) || TD_IS_RUNNING(td)), 1070 ("sched_add: bad thread state")); 1071 KASSERT(td->td_flags & TDF_INMEM, 1072 ("sched_add: thread swapped out")); 1073 CTR5(KTR_SCHED, "sched_add: %p(%s) prio %d by %p(%s)", | 684 685 THREAD_LOCK_ASSERT(td, MA_OWNED); 686 if (td->td_priority == prio) 687 return; 688 td->td_priority = prio; 689 if (TD_ON_RUNQ(td) && 690 td->td_sched->ts_rqindex != (prio / RQ_PPQ)) { 691 sched_rem(td); --- 374 unchanged lines hidden (view full) --- 1066 THREAD_LOCK_ASSERT(td, MA_OWNED); 1067 KASSERT((td->td_inhibitors == 0), 1068 ("sched_add: trying to run inhibited thread")); 1069 KASSERT((TD_CAN_RUN(td) || TD_IS_RUNNING(td)), 1070 ("sched_add: bad thread state")); 1071 KASSERT(td->td_flags & TDF_INMEM, 1072 ("sched_add: thread swapped out")); 1073 CTR5(KTR_SCHED, "sched_add: %p(%s) prio %d by %p(%s)", |
1074 td, td->td_proc->p_comm, td->td_priority, curthread, 1075 curthread->td_proc->p_comm); | 1074 td, td->td_name, td->td_priority, curthread, 1075 curthread->td_name); |
1076 /* 1077 * Now that the thread is moving to the run-queue, set the lock 1078 * to the scheduler's lock. 1079 */ 1080 if (td->td_lock != &sched_lock) { 1081 mtx_lock_spin(&sched_lock); 1082 thread_lock_set(td, &sched_lock); 1083 } --- 51 unchanged lines hidden (view full) --- 1135 THREAD_LOCK_ASSERT(td, MA_OWNED); 1136 KASSERT((td->td_inhibitors == 0), 1137 ("sched_add: trying to run inhibited thread")); 1138 KASSERT((TD_CAN_RUN(td) || TD_IS_RUNNING(td)), 1139 ("sched_add: bad thread state")); 1140 KASSERT(td->td_flags & TDF_INMEM, 1141 ("sched_add: thread swapped out")); 1142 CTR5(KTR_SCHED, "sched_add: %p(%s) prio %d by %p(%s)", | 1076 /* 1077 * Now that the thread is moving to the run-queue, set the lock 1078 * to the scheduler's lock. 1079 */ 1080 if (td->td_lock != &sched_lock) { 1081 mtx_lock_spin(&sched_lock); 1082 thread_lock_set(td, &sched_lock); 1083 } --- 51 unchanged lines hidden (view full) --- 1135 THREAD_LOCK_ASSERT(td, MA_OWNED); 1136 KASSERT((td->td_inhibitors == 0), 1137 ("sched_add: trying to run inhibited thread")); 1138 KASSERT((TD_CAN_RUN(td) || TD_IS_RUNNING(td)), 1139 ("sched_add: bad thread state")); 1140 KASSERT(td->td_flags & TDF_INMEM, 1141 ("sched_add: thread swapped out")); 1142 CTR5(KTR_SCHED, "sched_add: %p(%s) prio %d by %p(%s)", |
1143 td, td->td_proc->p_comm, td->td_priority, curthread, 1144 curthread->td_proc->p_comm); | 1143 td, td->td_name, td->td_priority, curthread, 1144 curthread->td_name); |
1145 /* 1146 * Now that the thread is moving to the run-queue, set the lock 1147 * to the scheduler's lock. 1148 */ 1149 if (td->td_lock != &sched_lock) { 1150 mtx_lock_spin(&sched_lock); 1151 thread_lock_set(td, &sched_lock); 1152 } --- 30 unchanged lines hidden (view full) --- 1183 1184 ts = td->td_sched; 1185 KASSERT(td->td_flags & TDF_INMEM, 1186 ("sched_rem: thread swapped out")); 1187 KASSERT(TD_ON_RUNQ(td), 1188 ("sched_rem: thread not on run queue")); 1189 mtx_assert(&sched_lock, MA_OWNED); 1190 CTR5(KTR_SCHED, "sched_rem: %p(%s) prio %d by %p(%s)", | 1145 /* 1146 * Now that the thread is moving to the run-queue, set the lock 1147 * to the scheduler's lock. 1148 */ 1149 if (td->td_lock != &sched_lock) { 1150 mtx_lock_spin(&sched_lock); 1151 thread_lock_set(td, &sched_lock); 1152 } --- 30 unchanged lines hidden (view full) --- 1183 1184 ts = td->td_sched; 1185 KASSERT(td->td_flags & TDF_INMEM, 1186 ("sched_rem: thread swapped out")); 1187 KASSERT(TD_ON_RUNQ(td), 1188 ("sched_rem: thread not on run queue")); 1189 mtx_assert(&sched_lock, MA_OWNED); 1190 CTR5(KTR_SCHED, "sched_rem: %p(%s) prio %d by %p(%s)", |
1191 td, td->td_proc->p_comm, td->td_priority, curthread, 1192 curthread->td_proc->p_comm); | 1191 td, td->td_name, td->td_priority, curthread, 1192 curthread->td_name); |
1193 1194 if ((td->td_proc->p_flag & P_NOLOAD) == 0) 1195 sched_load_rem(); 1196 runq_remove(ts->ts_runq, ts); 1197 TD_SET_CAN_RUN(td); 1198} 1199 1200/* --- 204 unchanged lines hidden --- | 1193 1194 if ((td->td_proc->p_flag & P_NOLOAD) == 0) 1195 sched_load_rem(); 1196 runq_remove(ts->ts_runq, ts); 1197 TD_SET_CAN_RUN(td); 1198} 1199 1200/* --- 204 unchanged lines hidden --- |