base: new 'Ram_allocator' interface

The 'Ram_allocator' interface contains the subset of the RAM session
interface that is needed to satisfy the needs of the 'Heap' and
'Sliced_heap'. Its small size makes it ideal for intercepting memory
allocations as done by the new 'Constrained_ram_allocator' wrapper
class, which is meant to replace the existing 'base/allocator_guard.h'
and 'os/ram_session_guard.h'.

Issue #2398
This commit is contained in:
Norman Feske
2017-05-07 23:49:43 +02:00
committed by Christian Helmuth
parent 5a468919bb
commit ff68d77c7d
21 changed files with 297 additions and 136 deletions

View File

@ -48,7 +48,7 @@ namespace Genode {
{
private:
Lock _lock;
Lock mutable _lock;
public:
@ -82,6 +82,12 @@ namespace Genode {
RAM_SESSION_IMPL::free(ds);
}
size_t dataspace_size(Ram_dataspace_capability ds) const override
{
Lock::Guard lock_guard(_lock);
return RAM_SESSION_IMPL::dataspace_size(ds);
}
int ref_account(Ram_session_capability session)
{
Lock::Guard lock_guard(_lock);

View File

@ -100,7 +100,7 @@ namespace Genode {
/**
* Check if dataspace is owned by a specified object
*/
bool owner(Dataspace_owner * const o) const { return _owner == o; }
bool owner(Dataspace_owner const *o) const { return _owner == o; }
/**
* Detach dataspace from all rm sessions.

View File

@ -78,23 +78,24 @@ class Stack_area_region_map : public Genode::Region_map
};
class Stack_area_ram_session : public Genode::Ram_session
struct Stack_area_ram_session : Genode::Ram_session
{
public:
Genode::Ram_dataspace_capability alloc(Genode::size_t size,
Genode::Cache_attribute) {
return Genode::Ram_dataspace_capability(); }
Genode::Ram_dataspace_capability alloc(Genode::size_t size,
Genode::Cache_attribute) override {
return Genode::Ram_dataspace_capability(); }
void free(Genode::Ram_dataspace_capability) { }
void free(Genode::Ram_dataspace_capability) override { }
int ref_account(Genode::Ram_session_capability) { return 0; }
Genode::size_t dataspace_size(Genode::Ram_dataspace_capability) const override { return 0; }
int transfer_quota(Genode::Ram_session_capability, Genode::size_t) { return 0; }
int ref_account(Genode::Ram_session_capability) override { return 0; }
Genode::size_t quota() { return 0; }
int transfer_quota(Genode::Ram_session_capability, Genode::size_t) override { return 0; }
Genode::size_t used() { return 0; }
Genode::size_t quota() override { return 0; }
Genode::size_t used() override { return 0; }
};