mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 20:42:56 +01:00
hw: avoid state & code duplication in scheduler
The `_head_was_removed` variable got introduced in solving #4710, but it reflects only whether `_head` is a valid pointer or not, thereby it duplicates state. Ref genodelabs/genode#5115
This commit is contained in:
committed by
Christian Helmuth
parent
ecd7b0568b
commit
776c2a6046
@@ -178,27 +178,19 @@ void Cpu_scheduler::update(time_t time)
|
||||
unsigned duration = (unsigned) (time - _last_time);
|
||||
_last_time = time;
|
||||
_need_to_schedule = false;
|
||||
unsigned const r = _trim_consumption(duration);
|
||||
|
||||
/* do not detract the quota if the head context was removed even now */
|
||||
if (_head) {
|
||||
unsigned const r = _trim_consumption(duration);
|
||||
|
||||
if (_head_claims)
|
||||
_head_claimed(r);
|
||||
else
|
||||
_head_filled(r);
|
||||
|
||||
_head_yields = false;
|
||||
_consumed(duration);
|
||||
|
||||
} else if (_head_was_removed) {
|
||||
|
||||
_trim_consumption(duration);
|
||||
_head_was_removed = false;
|
||||
_head_yields = false;
|
||||
_consumed(duration);
|
||||
}
|
||||
|
||||
_head_yields = false;
|
||||
_consumed(duration);
|
||||
|
||||
if (_claim_for_head())
|
||||
return;
|
||||
|
||||
@@ -276,10 +268,8 @@ 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;
|
||||
|
||||
@@ -134,7 +134,6 @@ 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;
|
||||
|
||||
Reference in New Issue
Block a user