mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 20:42:56 +01:00
hw: rename Cpu_scheduler variables
Give certain scheduler class wide variables and functions clear names: * quota => super_period_length * residual => super_period_left Ref genodelabs/genode#5115
This commit is contained in:
committed by
Christian Helmuth
parent
8e2c95e5e4
commit
2f727fb5c6
@@ -31,19 +31,15 @@ void Cpu_scheduler::_reset_claims(unsigned const p)
|
||||
}
|
||||
|
||||
|
||||
void Cpu_scheduler::_next_round()
|
||||
{
|
||||
_residual = _quota;
|
||||
_for_each_prio([&] (Cpu_priority const p, bool &) { _reset_claims(p); });
|
||||
}
|
||||
|
||||
|
||||
void Cpu_scheduler::_consumed(unsigned const q)
|
||||
{
|
||||
if (_residual > q)
|
||||
_residual -= q;
|
||||
else
|
||||
_next_round();
|
||||
if (_super_period_left > q) {
|
||||
_super_period_left -= q;
|
||||
return;
|
||||
}
|
||||
|
||||
_super_period_left = _super_period_length;
|
||||
_for_each_prio([&] (Cpu_priority const p, bool &) { _reset_claims(p); });
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +123,7 @@ bool Cpu_scheduler::_fill_for_head()
|
||||
|
||||
unsigned Cpu_scheduler::_trim_consumption(unsigned &q)
|
||||
{
|
||||
q = Genode::min(Genode::min(q, _head_quota), _residual);
|
||||
q = Genode::min(Genode::min(q, _head_quota), _super_period_left);
|
||||
if (!_head_yields)
|
||||
return _head_quota - q;
|
||||
|
||||
@@ -299,9 +295,14 @@ Cpu_share &Cpu_scheduler::head()
|
||||
}
|
||||
|
||||
|
||||
Cpu_scheduler::Cpu_scheduler(Share &i, unsigned const q, unsigned const f)
|
||||
Cpu_scheduler::Cpu_scheduler(Share &idle,
|
||||
unsigned const super_period_length,
|
||||
unsigned const f)
|
||||
:
|
||||
_idle(i), _quota(q), _residual(q), _fill(f)
|
||||
_idle(idle),
|
||||
_super_period_length(super_period_length),
|
||||
_super_period_left(super_period_length),
|
||||
_fill(f)
|
||||
{
|
||||
_set_head(i, f, 0);
|
||||
_set_head(idle, f, 0);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace Cpu_scheduler_test {
|
||||
*/
|
||||
class Cpu_scheduler;
|
||||
class Cpu_share;
|
||||
class Main;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,6 +124,7 @@ class Kernel::Cpu_share
|
||||
class Kernel::Cpu_scheduler
|
||||
{
|
||||
friend class Cpu_scheduler_test::Cpu_scheduler;
|
||||
friend class Cpu_scheduler_test::Main;
|
||||
|
||||
private:
|
||||
|
||||
@@ -204,8 +206,8 @@ class Kernel::Cpu_scheduler
|
||||
unsigned _head_quota = 0;
|
||||
bool _head_claims = false;
|
||||
bool _head_yields = false;
|
||||
unsigned const _quota;
|
||||
unsigned _residual;
|
||||
unsigned const _super_period_length;
|
||||
unsigned _super_period_left;
|
||||
unsigned const _fill;
|
||||
bool _need_to_schedule { true };
|
||||
time_t _last_time { 0 };
|
||||
@@ -223,7 +225,6 @@ class Kernel::Cpu_scheduler
|
||||
static void _reset(Cpu_share &share);
|
||||
|
||||
void _reset_claims(unsigned const p);
|
||||
void _next_round();
|
||||
void _consumed(unsigned const q);
|
||||
void _set_head(Share &s, unsigned const q, bool const c);
|
||||
void _head_claimed(unsigned const r);
|
||||
@@ -302,10 +303,9 @@ class Kernel::Cpu_scheduler
|
||||
*/
|
||||
|
||||
Share &head();
|
||||
|
||||
unsigned head_quota() const {
|
||||
return Genode::min(_head_quota, _residual); }
|
||||
unsigned quota() const { return _quota; }
|
||||
unsigned residual() const { return _residual; }
|
||||
return Genode::min(_head_quota, _super_period_left); }
|
||||
};
|
||||
|
||||
#endif /* _CORE__KERNEL__CPU_SCHEDULER_H_ */
|
||||
|
||||
@@ -193,7 +193,7 @@ class Cpu_scheduler_test::Main
|
||||
_current_time += consumed_quota;
|
||||
_scheduler.update(_current_time);
|
||||
unsigned const round_time {
|
||||
_scheduler.quota() - _scheduler.residual() };
|
||||
_scheduler._super_period_length - _scheduler._super_period_left };
|
||||
|
||||
if (round_time != expected_round_time) {
|
||||
|
||||
@@ -263,7 +263,7 @@ void Cpu_scheduler_test::Cpu_scheduler::print(Output &output) const
|
||||
using Genode::print;
|
||||
|
||||
print(output, "(\n");
|
||||
print(output, " quota: ", _residual, "/", _quota, ", ");
|
||||
print(output, " quota: ", _super_period_left, "/", _super_period_length, ", ");
|
||||
print(output, "fill: ", _fill, ", ");
|
||||
print(output, "need to schedule: ", _need_to_schedule ? "true" : "false", ", ");
|
||||
print(output, "last_time: ", _last_time);
|
||||
|
||||
Reference in New Issue
Block a user