From ab298b6337f1c938abccf52b7c8f9867279cfdd7 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Mon, 12 Dec 2022 08:19:51 +0100 Subject: [PATCH] base-hw scheduler: fix ready method Setting the _need_to_schedule member in the 'ready' method of the scheduler was not done correctly. At least, the _need_to_schedule was set true in situations were the head was not outdated by the 'ready' operation. Ref #4151 --- .../base-hw/src/core/kernel/cpu_scheduler.cc | 55 ++++++++----------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/repos/base-hw/src/core/kernel/cpu_scheduler.cc b/repos/base-hw/src/core/kernel/cpu_scheduler.cc index b56d771656..62184c2a4a 100644 --- a/repos/base-hw/src/core/kernel/cpu_scheduler.cc +++ b/repos/base-hw/src/core/kernel/cpu_scheduler.cc @@ -196,43 +196,34 @@ void Cpu_scheduler::ready(Share &s) assert(!s._ready && &s != &_idle); s._ready = 1; + if (s._quota) { + + _ucl[s._prio].remove(&s._claim_item); + if (s._claim) { + + _rcl[s._prio].insert_head(&s._claim_item); + if (_head && _head_claims) { + + if (s._prio >= _head->_prio) { + + _need_to_schedule = true; + } + } else { + + _need_to_schedule = true; + } + } else { + + _rcl[s._prio].insert_tail(&s._claim_item);; + } + } + s._fill = _fill; _fills.insert_tail(&s._fill_item); + if (!_head || _head == &_idle) { - if (_head == &_idle) _need_to_schedule = true; - - if (!s._quota) - return; - - _ucl[s._prio].remove(&s._claim_item); - - if (s._claim) - _rcl[s._prio].insert_head(&s._claim_item); - else - _rcl[s._prio].insert_tail(&s._claim_item); - - /* - * Check whether we need to re-schedule - */ - if (_need_to_schedule) - return; - - /* current head has no quota left */ - if (!_head_claims) { - _need_to_schedule = true; - return; } - - /* if current head has different priority */ - if (s._prio != _head->_prio) { - _need_to_schedule = s._prio > _head->_prio; - return; - } - - /* if current head has same priority, the ready share gets active */ - if (s._claim) - _need_to_schedule = true; }