mcs: Update ksDomainTime in updateTimestamp
When ksDomainTime reaches 0 the current domain expires and the next domain is switched to. This change performs the domain time accounting in one place, in updateTimestamp, and avoids situations where ksConsumed is reset without also updating ksDomainTime such as in chargeBudget. Calling rescheduleRequired in the domain expires ensures that a new thread will be chosen in the scheduler after the domain has been advanced. Any remaining ksConsumed will be charged to the outgoing scheduling context when it is switched away from. Signed-off-by: Kent McLeod <kent@kry10.com>
This commit is contained in:
parent
8373f0a0a6
commit
fa4f1baeb7
1 changed files with 16 additions and 13 deletions
|
|
@ -118,7 +118,7 @@ static inline bool_t PURE isRoundRobin(sched_context_t *sc)
|
|||
static inline bool_t isCurDomainExpired(void)
|
||||
{
|
||||
return CONFIG_NUM_DOMAINS > 1 &&
|
||||
ksDomainTime < (NODE_STATE(ksConsumed) + MIN_BUDGET);
|
||||
ksDomainTime == 0;
|
||||
}
|
||||
|
||||
static inline void commitTime(void)
|
||||
|
|
@ -145,15 +145,6 @@ static inline void commitTime(void)
|
|||
}
|
||||
NODE_STATE(ksCurSC)->scConsumed += NODE_STATE(ksConsumed);
|
||||
}
|
||||
if (CONFIG_NUM_DOMAINS > 1) {
|
||||
assert(ksDomainTime > NODE_STATE(ksConsumed));
|
||||
assert(ksDomainTime - NODE_STATE(ksConsumed) >= MIN_BUDGET);
|
||||
if (NODE_STATE(ksConsumed) < ksDomainTime) {
|
||||
ksDomainTime -= NODE_STATE(ksConsumed);
|
||||
} else {
|
||||
ksDomainTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
NODE_STATE(ksConsumed) = 0llu;
|
||||
}
|
||||
|
|
@ -234,7 +225,21 @@ static inline void updateTimestamp(void)
|
|||
{
|
||||
time_t prev = NODE_STATE(ksCurTime);
|
||||
NODE_STATE(ksCurTime) = getCurrentTime();
|
||||
NODE_STATE(ksConsumed) += (NODE_STATE(ksCurTime) - prev);
|
||||
time_t consumed = (NODE_STATE(ksCurTime) - prev);
|
||||
NODE_STATE(ksConsumed) += consumed;
|
||||
if (CONFIG_NUM_DOMAINS > 1) {
|
||||
|
||||
if ((consumed + MIN_BUDGET) >= ksDomainTime) {
|
||||
ksDomainTime = 0;
|
||||
} else {
|
||||
ksDomainTime -= consumed;
|
||||
}
|
||||
if (unlikely(isCurDomainExpired())) {
|
||||
NODE_STATE(ksReprogram) = true;
|
||||
rescheduleRequired();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* if the budget isn't enough, the timeslice for this SC is over. For
|
||||
|
|
@ -261,8 +266,6 @@ static inline bool_t checkBudget(void)
|
|||
|
||||
if (likely(isSufficientAndSplittable())) {
|
||||
if (unlikely(isCurDomainExpired())) {
|
||||
NODE_STATE(ksReprogram) = true;
|
||||
rescheduleRequired();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue