Fixed scheduler trying to access unallocated workers on invalid channels.

This commit is contained in:
Michael Müller
2022-07-26 18:07:15 +02:00
parent e0b2605dfe
commit 35065cfef8

View File

@@ -31,10 +31,10 @@ Scheduler::Scheduler(const mx::util::core_set &core_set, const std::uint16_t pre
Scheduler::~Scheduler() noexcept Scheduler::~Scheduler() noexcept
{ {
for (auto *worker : this->_worker) for (int channel; channel < this->_count_channels; channel++)
{ {
worker->~Worker(); _worker[channel]->~Worker();
memory::GlobalHeap::free(worker, sizeof(Worker)); memory::GlobalHeap::free(_worker[channel], sizeof(Worker));
} }
} }
@@ -60,9 +60,9 @@ void Scheduler::start_and_wait()
// Wait for the worker threads to end. This will only // Wait for the worker threads to end. This will only
// reached when the _is_running flag is set to false // reached when the _is_running flag is set to false
// from somewhere in the application. // from somewhere in the application.
for (auto *worker : this->_worker) for (int channel = 0; channel < this->_count_channels; channel++)
{ {
worker->join(); _worker[channel]->join();
} }
Genode::log("All workers finished."); Genode::log("All workers finished.");