summaryrefslogtreecommitdiffstats
path: root/sys/kern/sched_4bsd.c
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2003-01-12 19:04:49 +0000
committerjeff <jeff@FreeBSD.org>2003-01-12 19:04:49 +0000
commitde2bc350efdd9fcff91ebde7e16ed211d30f471e (patch)
tree353104f30f623f4560dd01c05bcc3cd0ed25fea2 /sys/kern/sched_4bsd.c
parentc7f5828c5e95d5202d48f85333d3afabc93bf6e8 (diff)
downloadFreeBSD-src-de2bc350efdd9fcff91ebde7e16ed211d30f471e.zip
FreeBSD-src-de2bc350efdd9fcff91ebde7e16ed211d30f471e.tar.gz
- Move ke_pctcpu and ke_cpticks into the scheduler specific datastructure.
This will prevent access through mechanisms other than the published interfaces.
Diffstat (limited to 'sys/kern/sched_4bsd.c')
-rw-r--r--sys/kern/sched_4bsd.c45
1 files changed, 30 insertions, 15 deletions
diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c
index 48020aa..344422b 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);
}
OpenPOWER on IntegriCloud