From 45cab8fed6fbad931c2affa81c94c98b6631bf7e Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Wed, 8 Mar 2017 10:26:39 +0100 Subject: [PATCH] hw: destroy active scheduling context (fix #1537) * In addition fixes routes of the cpu_scheduler.run test --- repos/base-hw/run/cpu_scheduler.run | 4 +++ .../base-hw/src/core/kernel/cpu_scheduler.cc | 25 ++++++++----------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/repos/base-hw/run/cpu_scheduler.run b/repos/base-hw/run/cpu_scheduler.run index 05e4c57e7..75e458b15 100644 --- a/repos/base-hw/run/cpu_scheduler.run +++ b/repos/base-hw/run/cpu_scheduler.run @@ -16,6 +16,10 @@ install_config { + + + + diff --git a/repos/base-hw/src/core/kernel/cpu_scheduler.cc b/repos/base-hw/src/core/kernel/cpu_scheduler.cc index ad34fdbd9..33b2c5492 100644 --- a/repos/base-hw/src/core/kernel/cpu_scheduler.cc +++ b/repos/base-hw/src/core/kernel/cpu_scheduler.cc @@ -132,10 +132,14 @@ void Cpu_scheduler::_quota_adaption(Share * const s, unsigned const q) void Cpu_scheduler::update(unsigned q) { - unsigned const r = _trim_consumption(q); - if (_head_claims) { _head_claimed(r); } - else { _head_filled(r); } - _consumed(q); + /* do not detract the quota if the head context was removed even now */ + if (_head) { + unsigned const r = _trim_consumption(q); + if (_head_claims) { _head_claimed(r); } + else { _head_filled(r); } + _consumed(q); + } + if (_claim_for_head()) { return; } if (_fill_for_head()) { return; } _set_head(_idle, _fill, 0); @@ -144,6 +148,8 @@ void Cpu_scheduler::update(unsigned q) bool Cpu_scheduler::ready_check(Share * const s1) { + assert(_head); + ready(s1); Share * s2 = _head; if (!s1->_claim) { return s2 == _idle; } @@ -185,16 +191,7 @@ void Cpu_scheduler::remove(Share * const s) { assert(s != _idle); - /* - * FIXME - * Thanks to helping, this can happen and shall not be treated as bad - * behavior. But by now, we have no stable solution for it. - * - */ - if (s == _head) { - Genode::error("Removing the head of the CPU scheduler isn't supported by now."); - while (1) ; - } + if (s == _head) _head = nullptr; if (s->_ready) { _fills.remove(s); } if (!s->_quota) { return; } if (s->_ready) { _rcl[s->_prio].remove(s); }