base: use mutex in heap

Issue #3612
This commit is contained in:
Alexander Boettcher 2020-01-24 13:59:27 +01:00 committed by Christian Helmuth
parent 00f69bc70d
commit 2bd77722c7
3 changed files with 8 additions and 8 deletions

View File

@ -19,7 +19,7 @@
#include <base/ram_allocator.h>
#include <region_map/region_map.h>
#include <base/allocator_avl.h>
#include <base/lock.h>
#include <base/mutex.h>
namespace Genode {
@ -89,7 +89,7 @@ class Genode::Heap : public Allocator
ram_alloc = ram, region_map = rm; }
};
Lock mutable _lock { };
Mutex mutable _mutex { };
Reconstructible<Allocator_avl> _alloc; /* local allocator */
Dataspace_pool _ds_pool; /* list of dataspaces */
size_t _quota_limit { 0 };
@ -157,7 +157,7 @@ class Genode::Heap : public Allocator
template <typename FN>
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())
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 */
size_t _consumed = 0; /* number of allocated bytes */
List<Block> _blocks { }; /* list of allocated blocks */
Lock _lock { }; /* serialize allocations */
Mutex _mutex { }; /* serialize allocations */
public:

View File

@ -224,7 +224,7 @@ bool Heap::alloc(size_t size, void **out_addr)
error("attempt to allocate zero-size block from heap");
/* serialize access of heap functions */
Lock::Guard lock_guard(_lock);
Mutex::Guard guard(_mutex);
/* check requested allocation against 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)
{
/* serialize access of heap functions */
Lock::Guard lock_guard(_lock);
Mutex::Guard guard(_mutex);
/* try to find the size in our local allocator */
size_t const size = _alloc->size_at(addr);

View File

@ -65,7 +65,7 @@ bool Sliced_heap::alloc(size_t size, void **out_addr)
}
/* serialize access to block list */
Lock::Guard lock_guard(_lock);
Mutex::Guard guard(_mutex);
construct_at<Block>(block, ds_cap, size);
@ -85,7 +85,7 @@ void Sliced_heap::free(void *addr, size_t)
void *local_addr = nullptr;
{
/* serialize access to block list */
Lock::Guard lock_guard(_lock);
Mutex::Guard guard(_mutex);
/*
* The 'addr' argument points to the payload. We use pointer