heap: interface for obtaining backing-store info

The new 'Heap::for_each_region' method provides information about the
heap's used virtual-memory regions. This method allows for the
mirroring of the heap state as needed by 'fork'.

Issue #3478
This commit is contained in:
Norman Feske 2019-08-16 19:09:48 +02:00 committed by Christian Helmuth
parent 2cff12e1fb
commit 354e310c87
1 changed files with 12 additions and 1 deletions

View File

@ -89,7 +89,7 @@ class Genode::Heap : public Allocator
ram_alloc = ram, region_map = rm; }
};
Lock _lock { };
Lock mutable _lock { };
Reconstructible<Allocator_avl> _alloc; /* local allocator */
Dataspace_pool _ds_pool; /* list of dataspaces */
size_t _quota_limit { 0 };
@ -151,6 +151,17 @@ class Genode::Heap : public Allocator
void reassign_resources(Ram_allocator *ram, Region_map *rm) {
_ds_pool.reassign_resources(ram, rm); }
/**
* Call 'fn' with the start and size of each backing-store region
*/
template <typename FN>
void for_each_region(FN const &fn) const
{
Lock::Guard guard(_lock);
for (Dataspace const *ds = _ds_pool.first(); ds; ds = ds->next())
fn(ds->local_addr, ds->size);
}
/*************************
** Allocator interface **