base-hw scheduler: fix bug on removing head

The scheduler did not consider the consumed quota during a call to "update"
if the head that consumed the quota was removed from the scheduler. When this
occured, the internal round time did not advance as expected but remained at
its previous value untile the next call to "update" (without a removed head)
This commit introduces a new flag that is set only when the head gets removed
in order to detect and handle the situation correctly on the next call to
"update".

Ref #4151
Ref #4710
This commit is contained in:
Martin Stein 2022-12-26 12:48:37 +01:00 committed by Christian Helmuth
parent ab298b6337
commit f74962bdad
2 changed files with 11 additions and 1 deletions

View File

@ -179,6 +179,13 @@ void Cpu_scheduler::update(time_t time)
_head_filled(r);
_consumed(duration);
} else if (_head_was_removed) {
_trim_consumption(duration);
_head_was_removed = false;
_head_yields = false;
_consumed(duration);
}
if (_claim_for_head())
@ -258,8 +265,10 @@ void Cpu_scheduler::remove(Share &s)
if (s._ready) unready(s);
if (&s == _head)
if (&s == _head) {
_head = nullptr;
_head_was_removed = true;
}
if (!s._quota)
return;

View File

@ -120,6 +120,7 @@ class Kernel::Cpu_scheduler
unsigned _head_quota = 0;
bool _head_claims = false;
bool _head_yields = false;
bool _head_was_removed = false;
unsigned const _quota;
unsigned _residual;
unsigned const _fill;