mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 13:47:56 +00:00
parent
00f69bc70d
commit
2bd77722c7
@ -19,7 +19,7 @@
|
|||||||
#include <base/ram_allocator.h>
|
#include <base/ram_allocator.h>
|
||||||
#include <region_map/region_map.h>
|
#include <region_map/region_map.h>
|
||||||
#include <base/allocator_avl.h>
|
#include <base/allocator_avl.h>
|
||||||
#include <base/lock.h>
|
#include <base/mutex.h>
|
||||||
|
|
||||||
namespace Genode {
|
namespace Genode {
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ class Genode::Heap : public Allocator
|
|||||||
ram_alloc = ram, region_map = rm; }
|
ram_alloc = ram, region_map = rm; }
|
||||||
};
|
};
|
||||||
|
|
||||||
Lock mutable _lock { };
|
Mutex mutable _mutex { };
|
||||||
Reconstructible<Allocator_avl> _alloc; /* local allocator */
|
Reconstructible<Allocator_avl> _alloc; /* local allocator */
|
||||||
Dataspace_pool _ds_pool; /* list of dataspaces */
|
Dataspace_pool _ds_pool; /* list of dataspaces */
|
||||||
size_t _quota_limit { 0 };
|
size_t _quota_limit { 0 };
|
||||||
@ -157,7 +157,7 @@ class Genode::Heap : public Allocator
|
|||||||
template <typename FN>
|
template <typename FN>
|
||||||
void for_each_region(FN const &fn) const
|
void for_each_region(FN const &fn) const
|
||||||
{
|
{
|
||||||
Lock::Guard guard(_lock);
|
Mutex::Guard guard(_mutex);
|
||||||
for (Dataspace const *ds = _ds_pool.first(); ds; ds = ds->next())
|
for (Dataspace const *ds = _ds_pool.first(); ds; ds = ds->next())
|
||||||
fn(ds->local_addr, ds->size);
|
fn(ds->local_addr, ds->size);
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ class Genode::Sliced_heap : public Allocator
|
|||||||
Region_map &_region_map; /* region map of the address space */
|
Region_map &_region_map; /* region map of the address space */
|
||||||
size_t _consumed = 0; /* number of allocated bytes */
|
size_t _consumed = 0; /* number of allocated bytes */
|
||||||
List<Block> _blocks { }; /* list of allocated blocks */
|
List<Block> _blocks { }; /* list of allocated blocks */
|
||||||
Lock _lock { }; /* serialize allocations */
|
Mutex _mutex { }; /* serialize allocations */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ bool Heap::alloc(size_t size, void **out_addr)
|
|||||||
error("attempt to allocate zero-size block from heap");
|
error("attempt to allocate zero-size block from heap");
|
||||||
|
|
||||||
/* serialize access of heap functions */
|
/* serialize access of heap functions */
|
||||||
Lock::Guard lock_guard(_lock);
|
Mutex::Guard guard(_mutex);
|
||||||
|
|
||||||
/* check requested allocation against quota limit */
|
/* check requested allocation against quota limit */
|
||||||
if (size + _quota_used > _quota_limit)
|
if (size + _quota_used > _quota_limit)
|
||||||
@ -237,7 +237,7 @@ bool Heap::alloc(size_t size, void **out_addr)
|
|||||||
void Heap::free(void *addr, size_t)
|
void Heap::free(void *addr, size_t)
|
||||||
{
|
{
|
||||||
/* serialize access of heap functions */
|
/* serialize access of heap functions */
|
||||||
Lock::Guard lock_guard(_lock);
|
Mutex::Guard guard(_mutex);
|
||||||
|
|
||||||
/* try to find the size in our local allocator */
|
/* try to find the size in our local allocator */
|
||||||
size_t const size = _alloc->size_at(addr);
|
size_t const size = _alloc->size_at(addr);
|
||||||
|
@ -65,7 +65,7 @@ bool Sliced_heap::alloc(size_t size, void **out_addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* serialize access to block list */
|
/* serialize access to block list */
|
||||||
Lock::Guard lock_guard(_lock);
|
Mutex::Guard guard(_mutex);
|
||||||
|
|
||||||
construct_at<Block>(block, ds_cap, size);
|
construct_at<Block>(block, ds_cap, size);
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ void Sliced_heap::free(void *addr, size_t)
|
|||||||
void *local_addr = nullptr;
|
void *local_addr = nullptr;
|
||||||
{
|
{
|
||||||
/* serialize access to block list */
|
/* serialize access to block list */
|
||||||
Lock::Guard lock_guard(_lock);
|
Mutex::Guard guard(_mutex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The 'addr' argument points to the payload. We use pointer
|
* The 'addr' argument points to the payload. We use pointer
|
||||||
|
Loading…
Reference in New Issue
Block a user