mirror of
https://github.com/mmueller41/mxtasking.git
synced 2026-01-21 12:42:57 +01:00
Use singleton object to access GlobalHeap.
This commit is contained in:
@@ -13,10 +13,19 @@ namespace mx::memory {
|
||||
class GlobalHeap
|
||||
{
|
||||
private:
|
||||
static Genode::Heap _heap;
|
||||
Genode::Heap _heap;
|
||||
|
||||
public:
|
||||
static Genode::Heap &heap() { return _heap; }
|
||||
GlobalHeap() : _heap(Genode::Heap(system::Environment::env()->ram(), system::Environment::env()->rm())) {}
|
||||
|
||||
Genode::Heap &get_heap() { return _heap; }
|
||||
|
||||
static GlobalHeap &get_instance() {
|
||||
static GlobalHeap gheap;
|
||||
return gheap;
|
||||
}
|
||||
|
||||
static Genode::Heap &heap() { return GlobalHeap::get_instance().get_heap(); }
|
||||
|
||||
/**
|
||||
* Allocates the given size on the given NUMA node.
|
||||
@@ -28,7 +37,7 @@ public:
|
||||
static void *allocate(const std::uint8_t numa_node_id, const std::size_t size)
|
||||
{
|
||||
/* TODO: Use component's heap */
|
||||
_heap.alloc(size);
|
||||
return GlobalHeap::get_instance().heap().alloc(size);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,7 +50,7 @@ public:
|
||||
static void *allocate_cache_line_aligned(const std::size_t size)
|
||||
{
|
||||
/* TODO: Use component's heap, as std::aligned_alloc might not be thread-safe */
|
||||
return _heap.alloc(alignment_helper::next_multiple(size, 64UL));
|
||||
return GlobalHeap::get_instance().heap().alloc(alignment_helper::next_multiple(size, 64UL));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +60,7 @@ public:
|
||||
* @param size Size of the allocated object.
|
||||
*/
|
||||
static void free(void *memory, const std::size_t size) { /* TODO: Free via Genode component's heap */
|
||||
_heap.free(memory, size);
|
||||
GlobalHeap::heap().free(memory, size);
|
||||
}
|
||||
};
|
||||
} // namespace mx::memory
|
||||
@@ -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 (memory::GlobalHeap::heap())Timer::Connection(*system::Environment::env))
|
||||
: _is_running(is_running), _channel(channel), _timer (*new (memory::GlobalHeap::heap()) Timer::Connection(*system::Environment::env()))
|
||||
{
|
||||
_idle_ranges.reserve(1 << 16);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ Worker::Worker(const std::uint16_t id, const std::uint16_t target_core_id, const
|
||||
const util::maybe_atomic<bool> &is_running, const std::uint16_t prefetch_distance,
|
||||
memory::reclamation::LocalEpoch &local_epoch,
|
||||
const std::atomic<memory::reclamation::epoch_t> &global_epoch, profiling::Statistic &statistic) noexcept
|
||||
: Thread(*system::Environment::env, Name("Worker ", id), 4*4096, system::Environment::env->cpu().affinity_space().location_of_index(target_core_id), Weight(), system::Environment::env->cpu()),
|
||||
: Thread(*system::Environment::env(), Name("Worker ", id), 4*4096, system::Environment::env()->cpu().affinity_space().location_of_index(target_core_id), Weight(), system::Environment::env()->cpu()),
|
||||
_target_core_id(target_core_id), _prefetch_distance(prefetch_distance),
|
||||
_channel(id, target_numa_node_id, prefetch_distance), _local_epoch(local_epoch), _global_epoch(global_epoch),
|
||||
_statistic(statistic), _is_running(is_running)
|
||||
|
||||
Reference in New Issue
Block a user