Made mx::System::Environment::env a pointer since it can then be reset later.

This commit is contained in:
Michael Müller
2022-07-07 11:35:47 +02:00
parent 7ce43863aa
commit bbfe3c5934
5 changed files with 8 additions and 5 deletions

View File

@@ -63,7 +63,7 @@ public:
EpochManager(const std::uint16_t count_channels, dynamic::Allocator &allocator,
util::maybe_atomic<bool> &is_running) noexcept
:
Thread(system::Environment::env, Name("EpochManager"), 8192),
Thread(*system::Environment::env, Name("EpochManager"), 8192),
_count_channels(count_channels), _is_running(is_running), _allocator(allocator)
{
}
@@ -159,7 +159,7 @@ private:
std::atomic<epoch_t> _global_epoch{0U};
// Genode Timer object, needed for waking up periodically
Timer::Connection _timer { system::Environment::env };
Timer::Connection _timer { *system::Environment::env };
// Local epochs, one for every channel.
alignas(64) std::array<LocalEpoch, tasking::config::max_cores()> _local_epochs;

View File

@@ -0,0 +1,3 @@
#include "environment.h"
Genode::Env* mx::system::Environment::env = nullptr;

View File

@@ -13,7 +13,7 @@ public:
* @return Genode environment capability
*
*/
static Genode::Env &env;
static Genode::Env *env;

View File

@@ -36,7 +36,7 @@ public:
/**
* @return Number of available cores.
*/
static std::uint16_t count_cores() { return std::uint16_t(Environment::env.cpu().affinity_space().total());
static std::uint16_t count_cores() { return std::uint16_t(Environment::env->cpu().affinity_space().total());
}
};
} // namespace mx::system

View File

@@ -7,7 +7,7 @@
using namespace mx::tasking::profiling;
ProfilingTask::ProfilingTask(mx::util::maybe_atomic<bool> &is_running, mx::tasking::Channel &channel)
: _is_running(is_running), _channel(channel), _timer(*new Timer::Connection(system::Environment::env))
: _is_running(is_running), _channel(channel), _timer(*new Timer::Connection(*system::Environment::env))
{
_idle_ranges.reserve(1 << 16);
}