From a488bebcd21f1e39697ac09fdac970a06d6fb621 Mon Sep 17 00:00:00 2001 From: julian Date: Sun, 18 Jul 2004 23:36:13 +0000 Subject: When calling scheduler entrypoints for creating new threads and processes, specify "us" as the thread not the process/ksegrp/kse. You can always find the others from the thread but the converse is not true. Theorotically this would lead to runtime being allocated to the wrong entity in some cases though it is not clear how often this actually happenned. (would only affect threaded processes and would probably be pretty benign, but it WAS a bug..) Reviewed by: peter --- sys/kern/sched_4bsd.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'sys/kern/sched_4bsd.c') diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index c80214e..4bff511 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -536,24 +536,24 @@ sched_clock(struct thread *td) * aggregated all the estcpu into the 'built-in' ksegrp. */ void -sched_exit(struct proc *p, struct proc *p1) +sched_exit(struct proc *p, struct thread *td) { - sched_exit_kse(FIRST_KSE_IN_PROC(p), FIRST_KSE_IN_PROC(p1)); - sched_exit_ksegrp(FIRST_KSEGRP_IN_PROC(p), FIRST_KSEGRP_IN_PROC(p1)); - sched_exit_thread(FIRST_THREAD_IN_PROC(p), FIRST_THREAD_IN_PROC(p1)); + sched_exit_kse(FIRST_KSE_IN_PROC(p), td); + sched_exit_ksegrp(FIRST_KSEGRP_IN_PROC(p), td); + sched_exit_thread(FIRST_THREAD_IN_PROC(p), td); } void -sched_exit_kse(struct kse *ke, struct kse *child) +sched_exit_kse(struct kse *ke, struct thread *child) { } void -sched_exit_ksegrp(struct ksegrp *kg, struct ksegrp *child) +sched_exit_ksegrp(struct ksegrp *kg, struct thread *childtd) { mtx_assert(&sched_lock, MA_OWNED); - kg->kg_estcpu = ESTCPULIM(kg->kg_estcpu + child->kg_estcpu); + kg->kg_estcpu = ESTCPULIM(kg->kg_estcpu + childtd->td_ksegrp->kg_estcpu); } void @@ -564,24 +564,24 @@ sched_exit_thread(struct thread *td, struct thread *child) } void -sched_fork(struct proc *p, struct proc *p1) +sched_fork(struct thread *td, struct proc *p1) { - sched_fork_kse(FIRST_KSE_IN_PROC(p), FIRST_KSE_IN_PROC(p1)); - sched_fork_ksegrp(FIRST_KSEGRP_IN_PROC(p), FIRST_KSEGRP_IN_PROC(p1)); - sched_fork_thread(FIRST_THREAD_IN_PROC(p), FIRST_THREAD_IN_PROC(p1)); + sched_fork_kse(td, FIRST_KSE_IN_PROC(p1)); + sched_fork_ksegrp(td, FIRST_KSEGRP_IN_PROC(p1)); + sched_fork_thread(td, FIRST_THREAD_IN_PROC(p1)); } void -sched_fork_kse(struct kse *ke, struct kse *child) +sched_fork_kse(struct thread *td, struct kse *child) { child->ke_sched->ske_cpticks = 0; } void -sched_fork_ksegrp(struct ksegrp *kg, struct ksegrp *child) +sched_fork_ksegrp(struct thread *td, struct ksegrp *child) { mtx_assert(&sched_lock, MA_OWNED); - child->kg_estcpu = kg->kg_estcpu; + child->kg_estcpu = td->td_ksegrp->kg_estcpu; } void -- cgit v1.1