Deleted Added
full compact
sched_4bsd.c (145109) sched_4bsd.c (145256)
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 145109 2005-04-15 14:01:43Z maxim $");
36__FBSDID("$FreeBSD: head/sys/kern/sched_4bsd.c 145256 2005-04-19 04:01:25Z jkoshy $");
37
38#define kse td_sched
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>
45#include <sys/kthread.h>
46#include <sys/mutex.h>
47#include <sys/proc.h>
48#include <sys/resourcevar.h>
49#include <sys/sched.h>
50#include <sys/smp.h>
51#include <sys/sysctl.h>
52#include <sys/sx.h>
53#include <sys/turnstile.h>
54#include <machine/smp.h>
55
37
38#define kse td_sched
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>
45#include <sys/kthread.h>
46#include <sys/mutex.h>
47#include <sys/proc.h>
48#include <sys/resourcevar.h>
49#include <sys/sched.h>
50#include <sys/smp.h>
51#include <sys/sysctl.h>
52#include <sys/sx.h>
53#include <sys/turnstile.h>
54#include <machine/smp.h>
55
56#ifdef HWPMC_HOOKS
57#include <sys/pmckern.h>
58#endif
59
56/*
57 * INVERSE_ESTCPU_WEIGHT is only suitable for statclock() frequencies in
58 * the range 100-256 Hz (approximately).
59 */
60#define ESTCPULIM(e) \
61 min((e), INVERSE_ESTCPU_WEIGHT * (NICE_WEIGHT * (PRIO_MAX - PRIO_MIN) - \
62 RQ_PPQ) + INVERSE_ESTCPU_WEIGHT - 1)
63#ifdef SMP

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

954 newtd->td_kse->ke_flags |= KEF_DIDRUN;
955 TD_SET_RUNNING(newtd);
956 if ((newtd->td_proc->p_flag & P_NOLOAD) == 0)
957 sched_load_add();
958 } else {
959 newtd = choosethread();
960 }
961
60/*
61 * INVERSE_ESTCPU_WEIGHT is only suitable for statclock() frequencies in
62 * the range 100-256 Hz (approximately).
63 */
64#define ESTCPULIM(e) \
65 min((e), INVERSE_ESTCPU_WEIGHT * (NICE_WEIGHT * (PRIO_MAX - PRIO_MIN) - \
66 RQ_PPQ) + INVERSE_ESTCPU_WEIGHT - 1)
67#ifdef SMP

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

958 newtd->td_kse->ke_flags |= KEF_DIDRUN;
959 TD_SET_RUNNING(newtd);
960 if ((newtd->td_proc->p_flag & P_NOLOAD) == 0)
961 sched_load_add();
962 } else {
963 newtd = choosethread();
964 }
965
962 if (td != newtd)
966 if (td != newtd) {
967#ifdef HWPMC_HOOKS
968 if (PMC_PROC_IS_USING_PMCS(td->td_proc))
969 PMC_SWITCH_CONTEXT(td, PMC_FN_CSW_OUT);
970#endif
963 cpu_switch(td, newtd);
971 cpu_switch(td, newtd);
972#ifdef HWPMC_HOOKS
973 if (PMC_PROC_IS_USING_PMCS(td->td_proc))
974 PMC_SWITCH_CONTEXT(td, PMC_FN_CSW_IN);
975#endif
976 }
977
964 sched_lock.mtx_lock = (uintptr_t)td;
965 td->td_oncpu = PCPU_GET(cpuid);
966}
967
968void
969sched_wakeup(struct thread *td)
970{
971 struct ksegrp *kg;

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

1279void
1280sched_unbind(struct thread* td)
1281{
1282 mtx_assert(&sched_lock, MA_OWNED);
1283 td->td_kse->ke_flags &= ~KEF_BOUND;
1284}
1285
1286int
978 sched_lock.mtx_lock = (uintptr_t)td;
979 td->td_oncpu = PCPU_GET(cpuid);
980}
981
982void
983sched_wakeup(struct thread *td)
984{
985 struct ksegrp *kg;

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

1293void
1294sched_unbind(struct thread* td)
1295{
1296 mtx_assert(&sched_lock, MA_OWNED);
1297 td->td_kse->ke_flags &= ~KEF_BOUND;
1298}
1299
1300int
1301sched_is_bound(struct thread *td)
1302{
1303 mtx_assert(&sched_lock, MA_OWNED);
1304 return (td->td_kse->ke_flags & KEF_BOUND);
1305}
1306
1307int
1287sched_load(void)
1288{
1289 return (sched_tdcnt);
1290}
1291
1292int
1293sched_sizeof_ksegrp(void)
1294{

--- 25 unchanged lines hidden ---
1308sched_load(void)
1309{
1310 return (sched_tdcnt);
1311}
1312
1313int
1314sched_sizeof_ksegrp(void)
1315{

--- 25 unchanged lines hidden ---