diff --git a/repos/base-hw/src/core/kernel/cpu.h b/repos/base-hw/src/core/kernel/cpu.h index e47d1adf73..35ab1b0014 100644 --- a/repos/base-hw/src/core/kernel/cpu.h +++ b/repos/base-hw/src/core/kernel/cpu.h @@ -171,7 +171,7 @@ class Kernel::Cpu : public Genode::Cpu, private Irq::Pool, private Timeout /** * Returns the currently active job */ - Job & scheduled_job() const { + Job & scheduled_job() { return *static_cast(&_scheduler.head())->helping_destination(); } unsigned id() const { return _id; } diff --git a/repos/base-hw/src/core/kernel/cpu_scheduler.cc b/repos/base-hw/src/core/kernel/cpu_scheduler.cc index fd600e73d2..c97d49285d 100644 --- a/repos/base-hw/src/core/kernel/cpu_scheduler.cc +++ b/repos/base-hw/src/core/kernel/cpu_scheduler.cc @@ -313,9 +313,12 @@ void Cpu_scheduler::quota(Share &s, unsigned const q) } -Cpu_share &Cpu_scheduler::head() const +Cpu_share &Cpu_scheduler::head() { - assert(_head); + if (!_head) { + Genode::error("attempt to access invalid scheduler head"); + update(_last_time); + } return *_head; } diff --git a/repos/base-hw/src/core/kernel/cpu_scheduler.h b/repos/base-hw/src/core/kernel/cpu_scheduler.h index a1e4a0770f..4699292f40 100644 --- a/repos/base-hw/src/core/kernel/cpu_scheduler.h +++ b/repos/base-hw/src/core/kernel/cpu_scheduler.h @@ -233,7 +233,7 @@ class Kernel::Cpu_scheduler * Accessors */ - Share &head() const; + Share &head(); unsigned head_quota() const { return Genode::min(_head_quota, _residual); } unsigned quota() const { return _quota; }