core: use Mutex/Blockade

Issue #3612
This commit is contained in:
Alexander Boettcher
2020-02-18 15:29:47 +01:00
committed by Christian Helmuth
parent 85a1f91f59
commit e87d60ddf7
48 changed files with 218 additions and 232 deletions

View File

@@ -25,7 +25,7 @@ class Genode::Irq_object : public Thread_deprecated<4096> {
private:
Signal_context_capability _sig_cap { };
Lock _sync_bootup;
Blockade _sync_bootup { };
unsigned _irq;
Cap_sel _kernel_irq_sel;
Cap_sel _kernel_notify_sel;

View File

@@ -164,13 +164,13 @@ class Genode::Platform : public Platform_generic
struct Core_sel_alloc : Cap_sel_alloc, private Core_sel_bit_alloc
{
Lock _lock { };
Mutex _mutex { };
Core_sel_alloc() { _reserve(0, Core_cspace::core_static_sel_end()); }
Cap_sel alloc() override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
try {
return Cap_sel(Core_sel_bit_alloc::alloc()); }
@@ -180,7 +180,7 @@ class Genode::Platform : public Platform_generic
void free(Cap_sel sel) override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
Core_sel_bit_alloc::free(sel.value());
}

View File

@@ -58,7 +58,7 @@ class Genode::Platform_pd : public Address_space
};
Sel_alloc _sel_alloc { };
Lock _sel_alloc_lock { };
Mutex _sel_alloc_mutex { };
Cap_sel alloc_sel();
void free_sel(Cap_sel sel);

View File

@@ -156,7 +156,7 @@ class Genode::Vm_space
return Cnode_index(idx & (LEAF_CNODE_SIZE - 1));
}
Lock _lock { };
Mutex _mutex { };
/**
* Return selector for a capability slot within '_vm_cnodes'
@@ -406,7 +406,7 @@ class Genode::Vm_space
return true;
};
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
bool ok = true;
@@ -445,7 +445,7 @@ class Genode::Vm_space
return true;
};
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
for (size_t i = 0; i < num_pages; i++) {
off_t const offset = i << get_page_size_log2();
@@ -462,7 +462,7 @@ class Genode::Vm_space
{
bool unmap_success = true;
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
for (size_t i = 0; unmap_success && i < num_pages; i++) {
off_t const offset = i << get_page_size_log2();
@@ -499,13 +499,13 @@ class Genode::Vm_space
void alloc_page_tables(addr_t const start, addr_t const size)
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
unsynchronized_alloc_page_tables(start, size);
}
void alloc_guest_page_tables(addr_t const start, addr_t const size)
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
unsynchronized_alloc_guest_page_tables(start, size);
}

View File

@@ -62,14 +62,14 @@ void Irq_object::_wait_for_irq()
void Irq_object::start()
{
::Thread::start();
_sync_bootup.lock();
_sync_bootup.block();
}
void Irq_object::entry()
{
/* thread is up and ready */
_sync_bootup.unlock();
_sync_bootup.wakeup();
while (true) {
@@ -92,7 +92,6 @@ void Irq_object::ack_irq()
Irq_object::Irq_object(unsigned irq)
:
Thread_deprecated<4096>("irq"),
_sync_bootup(Lock::LOCKED),
_irq(irq),
_kernel_irq_sel(platform_specific().core_sel_alloc().alloc()),
_kernel_notify_sel(platform_specific().core_sel_alloc().alloc())

View File

@@ -142,7 +142,7 @@ void Platform_pd::assign_parent(Native_capability parent)
Cap_sel Platform_pd::alloc_sel()
{
Lock::Guard guard(_sel_alloc_lock);
Mutex::Guard guard(_sel_alloc_mutex);
return Cap_sel(_sel_alloc.alloc());
}
@@ -150,7 +150,7 @@ Cap_sel Platform_pd::alloc_sel()
void Platform_pd::free_sel(Cap_sel sel)
{
Lock::Guard guard(_sel_alloc_lock);
Mutex::Guard guard(_sel_alloc_mutex);
_sel_alloc.free(sel.value());
}

View File

@@ -38,19 +38,19 @@ class Platform_thread_registry : Noncopyable
private:
List<Platform_thread> _threads { };
Lock _lock { };
Mutex _mutex { };
public:
void insert(Platform_thread &thread)
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
_threads.insert(&thread);
}
void remove(Platform_thread &thread)
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
_threads.remove(&thread);
}
@@ -59,7 +59,7 @@ class Platform_thread_registry : Noncopyable
unsigned installed = 0;
bool result = true;
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
for (Platform_thread *t = _threads.first(); t; t = t->next()) {
if (t->pager_object_badge() == pager_object_badge) {

View File

@@ -15,8 +15,8 @@
#define _INCLUDE__BASE__INTERNAL__CAPABILITY_SPACE_SEL4_H_
/* base includes */
#include <base/mutex.h>
#include <util/avl_tree.h>
#include <base/lock.h>
#include <util/construct_at.h>
/* base-internal includes */
@@ -171,7 +171,7 @@ class Genode::Capability_space_sel4
Tree_managed_data _caps_data[NUM_CAPS];
Avl_tree<Tree_managed_data> _tree { };
Lock mutable _lock { };
Mutex mutable _mutex { };
/**
* Calculate index into _caps_data for capability data object
@@ -218,7 +218,7 @@ class Genode::Capability_space_sel4
ASSERT(sel < NUM_CAPS);
ASSERT(!_caps_data[sel].rpc_obj_key().valid());
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
construct_at<Tree_managed_data>(&_caps_data[sel], args...);
@@ -240,7 +240,7 @@ class Genode::Capability_space_sel4
void dec_ref(Data &data)
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
if (!_is_core_managed(data) && !data.dec_ref())
_remove(data);
@@ -248,7 +248,7 @@ class Genode::Capability_space_sel4
void inc_ref(Data &data)
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
if (!_is_core_managed(data)) {
data.inc_ref();
@@ -272,7 +272,7 @@ class Genode::Capability_space_sel4
Data *lookup(Rpc_obj_key key) const
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
if (!_tree.first())
return nullptr;

View File

@@ -62,7 +62,7 @@ namespace {
{
private:
Lock _lock { };
Mutex _mutex { };
public:
@@ -70,13 +70,13 @@ namespace {
unsigned alloc()
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
return Bit_allocator::alloc();
}
void free(unsigned sel)
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
Bit_allocator::free(sel);
}
};

View File

@@ -41,7 +41,7 @@ struct Vcpu : Genode::Thread
Semaphore _wake_up { 0 };
Semaphore &_handler_ready;
Allocator &_alloc;
Lock _startup { Genode::Lock::LOCKED };
Blockade _startup { };
Vm_session_client::Vcpu_id _id {};
addr_t _state { 0 };
addr_t _recall { 0 };
@@ -62,7 +62,7 @@ struct Vcpu : Genode::Thread
PAUSE = 1,
RUN = 2
} _remote { NONE };
Lock _remote_lock { Lock::UNLOCKED };
Mutex _remote_mutex { };
enum {
VMEXIT_INVALID = 0x21,
@@ -91,7 +91,7 @@ struct Vcpu : Genode::Thread
void entry() override
{
/* trigger that thread is up */
_startup.unlock();
_startup.wakeup();
/* wait until vcpu is assigned to us */
_wake_up.down();
@@ -108,7 +108,7 @@ struct Vcpu : Genode::Thread
_wake_up.down();
{
Lock::Guard guard(_remote_lock);
Mutex::Guard guard(_remote_mutex);
_remote = NONE;
}
@@ -129,7 +129,7 @@ struct Vcpu : Genode::Thread
while (true) {
/* read in requested state from remote threads */
{
Lock::Guard guard(_remote_lock);
Mutex::Guard guard(_remote_mutex);
local_state = _remote;
_remote = NONE;
@@ -173,7 +173,7 @@ struct Vcpu : Genode::Thread
if (local_state != RUN) {
Genode::error("unknown vcpu state ", (int)local_state);
while (true) { _remote_lock.lock(); }
while (true) { _remote_mutex.acquire(); }
}
_write_sel4_state(service, state);
@@ -195,7 +195,7 @@ struct Vcpu : Genode::Thread
_read_sel4_state(service, state);
if (res != SEL4_VMENTER_RESULT_FAULT) {
Lock::Guard guard(_remote_lock);
Mutex::Guard guard(_remote_mutex);
if (_remote == PAUSE) {
_remote = NONE;
_wake_up.down();
@@ -724,7 +724,7 @@ struct Vcpu : Genode::Thread
void start() override {
Thread::start();
_startup.lock();
_startup.block();
}
Genode::Vm_session_client::Vcpu_id id() const { return _id; }
@@ -740,7 +740,7 @@ struct Vcpu : Genode::Thread
void resume()
{
Lock::Guard guard(_remote_lock);
Mutex::Guard guard(_remote_mutex);
if (_remote == RUN || _remote == PAUSE)
return;
@@ -751,7 +751,7 @@ struct Vcpu : Genode::Thread
void pause()
{
Lock::Guard guard(_remote_lock);
Mutex::Guard guard(_remote_mutex);
if (_remote == PAUSE)
return;