diff options
author | Jeff Roberson <jeff@FreeBSD.org> | 2003-01-12 19:04:49 +0000 |
---|---|---|
committer | Jeff Roberson <jeff@FreeBSD.org> | 2003-01-12 19:04:49 +0000 |
commit | bcb06d5980ee854046682ce4a2d5f722ce8ed29c (patch) | |
tree | 353104f30f623f4560dd01c05bcc3cd0ed25fea2 /sys | |
parent | e5930ece05db8684b1a8f75ad9762947e8e1cf48 (diff) | |
download | src-bcb06d5980ee854046682ce4a2d5f722ce8ed29c.tar.gz src-bcb06d5980ee854046682ce4a2d5f722ce8ed29c.zip |
- Move ke_pctcpu and ke_cpticks into the scheduler specific datastructure.
This will prevent access through mechanisms other than the published
interfaces.
Notes
Notes:
svn path=/head/; revision=109145
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/sched_4bsd.c | 45 | ||||
-rw-r--r-- | sys/sys/proc.h | 2 |
2 files changed, 30 insertions, 17 deletions
diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 48020aaf4076..344422b4689f 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -61,7 +61,14 @@ #define INVERSE_ESTCPU_WEIGHT 8 /* 1 / (priorities per estcpu level). */ #define NICE_WEIGHT 1 /* Priorities per nice level. */ -struct ke_sched *kse0_sched = NULL; +struct ke_sched { + int ske_cpticks; /* (j) Ticks of cpu time. */ + fixpt_t ske_pctcpu; /* (j) %cpu during p_swtime. */ +}; + +struct ke_sched ke_sched; + +struct ke_sched *kse0_sched = &ke_sched; struct kg_sched *ksegrp0_sched = NULL; struct p_sched *proc0_sched = NULL; struct td_sched *thread0_sched = NULL; @@ -278,27 +285,28 @@ schedcpu(void *arg) * Do it per kse.. and add them up at the end? * XXXKSE */ - ke->ke_pctcpu - = (ke->ke_pctcpu * ccpu) >> FSHIFT; + ke->ke_sched->ske_pctcpu + = (ke->ke_sched->ske_pctcpu * ccpu) >> + FSHIFT; /* * If the kse has been idle the entire second, * stop recalculating its priority until * it wakes up. */ - if (ke->ke_cpticks == 0) + if (ke->ke_sched->ske_cpticks == 0) continue; #if (FSHIFT >= CCPU_SHIFT) - ke->ke_pctcpu += (realstathz == 100) ? - ((fixpt_t) ke->ke_cpticks) << + ke->ke_sched->ske_pctcpu += (realstathz == 100) + ? ((fixpt_t) ke->ke_sched->ske_cpticks) << (FSHIFT - CCPU_SHIFT) : - 100 * (((fixpt_t) ke->ke_cpticks) << - (FSHIFT - CCPU_SHIFT)) / realstathz; + 100 * (((fixpt_t) ke->ke_sched->ske_cpticks) + << (FSHIFT - CCPU_SHIFT)) / realstathz; #else - ke->ke_pctcpu += ((FSCALE - ccpu) * - (ke->ke_cpticks * FSCALE / realstathz)) >> - FSHIFT; + ke->ke_sched->ske_pctcpu += ((FSCALE - ccpu) * + (ke->ke_sched->ske_cpticks * + FSCALE / realstathz)) >> FSHIFT; #endif - ke->ke_cpticks = 0; + ke->ke_sched->ske_cpticks = 0; } /* end of kse loop */ /* * If there are ANY running threads in this KSEGRP, @@ -439,7 +447,7 @@ sched_clock(struct thread *td) KASSERT((td != NULL), ("schedclock: null thread pointer")); ke = td->td_kse; kg = td->td_ksegrp; - ke->ke_cpticks++; + ke->ke_sched->ske_cpticks++; kg->kg_estcpu = ESTCPULIM(kg->kg_estcpu + 1); if ((kg->kg_estcpu % INVERSE_ESTCPU_WEIGHT) == 0) { resetpriority(kg); @@ -464,11 +472,18 @@ sched_exit(struct ksegrp *kg, struct ksegrp *child) void sched_fork(struct ksegrp *kg, struct ksegrp *child) { + struct kse *ke; + /* * set priority of child to be that of parent. * XXXKSE this needs redefining.. */ child->kg_estcpu = kg->kg_estcpu; + + /* Set up scheduler specific data */ + ke = FIRST_KSE_IN_KSEGRP(kg); + ke->ke_sched->ske_pctcpu = 0; + ke->ke_sched->ske_cpticks = 0; } void @@ -631,7 +646,7 @@ sched_userret(struct thread *td) int sched_sizeof_kse(void) { - return (sizeof(struct kse)); + return (sizeof(struct kse) + sizeof(struct ke_sched)); } int sched_sizeof_ksegrp(void) @@ -652,5 +667,5 @@ sched_sizeof_thread(void) fixpt_t sched_pctcpu(struct kse *ke) { - return (ke->ke_pctcpu); + return (ke->ke_sched->ske_pctcpu); } diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 82a491956ec5..d6ef225a2a59 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -441,8 +441,6 @@ struct kse { int ke_flags; /* (j) KEF_* flags. */ struct thread *ke_thread; /* Active associated thread. */ struct thread *ke_owner; /* Always points to the owner */ - int ke_cpticks; /* (j) Ticks of cpu time. */ - fixpt_t ke_pctcpu; /* (j) %cpu during p_swtime. */ u_int64_t ke_uu; /* (j) Previous user time in usec. */ u_int64_t ke_su; /* (j) Previous system time in usec. */ u_int64_t ke_iu; /* (j) Previous intr time in usec. */ |