From e87d60ddf7ecfd44b9afd1a4591913740e7dfed1 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Tue, 18 Feb 2020 15:29:47 +0100 Subject: [PATCH] core: use Mutex/Blockade Issue #3612 --- .../src/core/irq_session_component.cc | 9 ++++---- .../base-foc/src/core/include/cap_id_alloc.h | 4 ++-- repos/base-foc/src/core/rpc_cap_factory.cc | 4 ++-- repos/base-foc/src/lib/base/x86/vm_session.cc | 16 ++++++------- repos/base-hw/src/core/platform_pd.cc | 4 ++-- repos/base-hw/src/core/platform_pd.h | 2 +- repos/base-hw/src/core/rpc_cap_factory.h | 10 ++++---- .../base-linux/src/core/include/irq_object.h | 4 ++-- .../core/spec/linux/irq_session_component.cc | 2 -- .../src/core/spec/pc/irq_session_component.cc | 12 ++++------ repos/base-linux/src/lib/base/thread_linux.cc | 14 +++++------ .../base-linux/src/lib/lx_hybrid/lx_hybrid.cc | 23 ++++++++----------- .../src/test/lx_hybrid_errno/main.cc | 10 ++++---- .../src/test/lx_hybrid_pthread_ipc/main.cc | 8 +++---- .../base-linux/src/timer/linux/time_source.cc | 2 +- repos/base-nova/include/nova/cap_map.h | 6 ++--- repos/base-nova/src/core/include/pager.h | 12 +++++----- .../src/core/include/rpc_cap_factory.h | 4 ++-- repos/base-nova/src/core/pager.cc | 20 ++++++++-------- repos/base-nova/src/core/rpc_cap_factory.cc | 6 ++--- repos/base-nova/src/lib/base/cap_map.cc | 6 ++--- .../src/core/irq_session_component.cc | 9 ++++---- .../src/core/irq_session_component.cc | 11 ++++----- repos/base-sel4/src/core/include/irq_object.h | 2 +- repos/base-sel4/src/core/include/platform.h | 6 ++--- .../base-sel4/src/core/include/platform_pd.h | 2 +- repos/base-sel4/src/core/include/vm_space.h | 12 +++++----- .../src/core/irq_session_component.cc | 5 ++-- repos/base-sel4/src/core/platform_pd.cc | 4 ++-- repos/base-sel4/src/core/platform_thread.cc | 8 +++---- .../base/internal/capability_space_sel4.h | 12 +++++----- .../src/lib/base/capability_space.cc | 6 ++--- .../base-sel4/src/lib/base/x86/vm_session.cc | 20 ++++++++-------- repos/base/src/core/cpu_session_component.cc | 22 +++++++++--------- repos/base/src/core/dataspace_component.cc | 12 +++++----- repos/base/src/core/include/account.h | 18 +++++++-------- .../src/core/include/cpu_session_component.h | 14 +++++------ .../src/core/include/dataspace_component.h | 4 ++-- repos/base/src/core/include/irq_object.h | 6 ++--- .../src/core/include/region_map_component.h | 8 +++---- .../src/core/include/rm_session_component.h | 8 +++---- repos/base/src/core/include/rpc_cap_factory.h | 6 ++--- .../src/core/include/synced_ram_allocator.h | 10 ++++---- .../src/core/include/trace/policy_registry.h | 16 ++++++------- .../src/core/include/trace/source_registry.h | 8 +++---- .../src/core/include/trace/subject_registry.h | 14 +++++------ repos/base/src/core/region_map_component.cc | 23 +++++++++---------- repos/base/src/core/rpc_cap_factory.cc | 6 ++--- 48 files changed, 218 insertions(+), 232 deletions(-) diff --git a/repos/base-fiasco/src/core/irq_session_component.cc b/repos/base-fiasco/src/core/irq_session_component.cc index 8e4cfba33..d91308ab2 100644 --- a/repos/base-fiasco/src/core/irq_session_component.cc +++ b/repos/base-fiasco/src/core/irq_session_component.cc @@ -82,7 +82,7 @@ void Irq_object::_wait_for_irq() void Irq_object::start() { ::Thread::start(); - _sync_bootup.lock(); + _sync_bootup.block(); } @@ -94,10 +94,10 @@ void Irq_object::entry() } /* thread is up and ready */ - _sync_bootup.unlock(); + _sync_bootup.wakeup(); /* wait for first ack_irq */ - _sync_ack.lock(); + _sync_ack.block(); while (true) { @@ -108,7 +108,7 @@ void Irq_object::entry() Genode::Signal_transmitter(_sig_cap).submit(1); - _sync_ack.lock(); + _sync_ack.block(); } } @@ -116,7 +116,6 @@ void Irq_object::entry() Irq_object::Irq_object(unsigned irq) : Thread_deprecated<4096>("irq"), - _sync_ack(Lock::LOCKED), _sync_bootup(Lock::LOCKED), _irq(irq) { } diff --git a/repos/base-foc/src/core/include/cap_id_alloc.h b/repos/base-foc/src/core/include/cap_id_alloc.h index 518728629..11084fed4 100644 --- a/repos/base-foc/src/core/include/cap_id_alloc.h +++ b/repos/base-foc/src/core/include/cap_id_alloc.h @@ -17,7 +17,7 @@ /* Genode includes */ #include #include -#include +#include #include namespace Genode { @@ -35,7 +35,7 @@ namespace Genode { Synced_range_allocator _id_alloc; - Lock _lock { }; + Mutex _mutex { }; public: diff --git a/repos/base-foc/src/core/rpc_cap_factory.cc b/repos/base-foc/src/core/rpc_cap_factory.cc index 3d4d75038..cacc652d9 100644 --- a/repos/base-foc/src/core/rpc_cap_factory.cc +++ b/repos/base-foc/src/core/rpc_cap_factory.cc @@ -192,7 +192,7 @@ Cap_id_allocator::Cap_id_allocator(Allocator &alloc) unsigned long Cap_id_allocator::alloc() { - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); void *id = nullptr; if (_id_alloc.alloc(CAP_ID_OFFSET, &id)) @@ -203,7 +203,7 @@ unsigned long Cap_id_allocator::alloc() void Cap_id_allocator::free(unsigned long id) { - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); if (id < CAP_ID_RANGE) _id_alloc.free((void*)(id & CAP_ID_MASK), CAP_ID_OFFSET); diff --git a/repos/base-foc/src/lib/base/x86/vm_session.cc b/repos/base-foc/src/lib/base/x86/vm_session.cc index 5911003ae..051b5121e 100644 --- a/repos/base-foc/src/lib/base/x86/vm_session.cc +++ b/repos/base-foc/src/lib/base/x86/vm_session.cc @@ -227,14 +227,14 @@ struct Vcpu : Genode::Thread State _state_request { NONE }; State _state_current { NONE }; - Lock _remote_lock { Lock::UNLOCKED }; + Mutex _remote_mutex { }; void entry() override { _wake_up.down(); { - Lock::Guard guard(_remote_lock); + Mutex::Guard guard(_remote_mutex); /* leave scope for Thread::join() - vCPU setup failed */ if (_state_request == TERMINATE) @@ -319,7 +319,7 @@ struct Vcpu : Genode::Thread while (true) { /* read in requested state from remote threads */ { - Lock::Guard guard(_remote_lock); + Mutex::Guard guard(_remote_mutex); _state_current = _state_request; _state_request = NONE; } @@ -331,7 +331,7 @@ struct Vcpu : Genode::Thread if (_state_current != RUN && _state_current != PAUSE) { Genode::error("unknown vcpu state ", (int)_state_current); - while (true) { _remote_lock.lock(); } + while (true) { _remote_mutex.acquire(); } } /* transfer vCPU state to Fiasco.OC */ @@ -355,7 +355,7 @@ struct Vcpu : Genode::Thread reason = 0xfc; { - Lock::Guard guard(_remote_lock); + Mutex::Guard guard(_remote_mutex); _state_request = NONE; _state_current = PAUSE; @@ -380,7 +380,7 @@ struct Vcpu : Genode::Thread reason = Fiasco::l4_vm_vmx_read_32(vmcs, Vmcs::EXI_REASON); { - Lock::Guard guard(_remote_lock); + Mutex::Guard guard(_remote_mutex); _state_request = NONE; _state_current = PAUSE; @@ -1207,7 +1207,7 @@ struct Vcpu : Genode::Thread void resume() { - Lock::Guard guard(_remote_lock); + Mutex::Guard guard(_remote_mutex); if (_state_request == RUN || _state_request == PAUSE) return; @@ -1220,7 +1220,7 @@ struct Vcpu : Genode::Thread void pause() { - Lock::Guard guard(_remote_lock); + Mutex::Guard guard(_remote_mutex); if (_state_request == PAUSE) return; diff --git a/repos/base-hw/src/core/platform_pd.cc b/repos/base-hw/src/core/platform_pd.cc index b28ae2348..fcc3c22c7 100644 --- a/repos/base-hw/src/core/platform_pd.cc +++ b/repos/base-hw/src/core/platform_pd.cc @@ -49,7 +49,7 @@ bool Hw::Address_space::insert_translation(addr_t virt, addr_t phys, try { for (;;) { try { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); _tt.insert_translation(virt, phys, size, flags, _tt_alloc); return true; } catch(Hw::Out_of_tables &) { @@ -76,7 +76,7 @@ bool Hw::Address_space::lookup_translation(addr_t const virt, addr_t & phys) void Hw::Address_space::flush(addr_t virt, size_t size, Core_local_addr) { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); try { _tt.remove_translation(virt, size, _tt_alloc); diff --git a/repos/base-hw/src/core/platform_pd.h b/repos/base-hw/src/core/platform_pd.h index ceb680d81..aa7ecd653 100644 --- a/repos/base-hw/src/core/platform_pd.h +++ b/repos/base-hw/src/core/platform_pd.h @@ -72,7 +72,7 @@ class Hw::Address_space : public Genode::Address_space using Table = Hw::Page_table; using Array = Table::Allocator::Array; - Genode::Lock _lock { }; /* table lock */ + Genode::Mutex _mutex { }; /* table lock */ Table & _tt; /* table virt addr */ Genode::addr_t _tt_phys; /* table phys addr */ Array * _tt_array = nullptr; diff --git a/repos/base-hw/src/core/rpc_cap_factory.h b/repos/base-hw/src/core/rpc_cap_factory.h index 78bf6111b..4a768c9ed 100644 --- a/repos/base-hw/src/core/rpc_cap_factory.h +++ b/repos/base-hw/src/core/rpc_cap_factory.h @@ -17,7 +17,7 @@ /* Genode includes */ #include #include -#include +#include #include #include #include @@ -58,7 +58,7 @@ class Genode::Rpc_cap_factory uint8_t _initial_slab_block[get_page_size()]; Slab _slab; List _list { }; - Lock _lock { }; + Mutex _mutex { }; public: @@ -69,7 +69,7 @@ class Genode::Rpc_cap_factory ~Rpc_cap_factory() { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); while (Kobject * obj = _list.first()) { _list.remove(obj); @@ -84,7 +84,7 @@ class Genode::Rpc_cap_factory */ Native_capability alloc(Native_capability ep) { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); /* allocate kernel object */ Kobject * obj; @@ -106,7 +106,7 @@ class Genode::Rpc_cap_factory void free(Native_capability cap) { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); for (Kobject * obj = _list.first(); obj; obj = obj->next()) { if (obj->cap.data() == cap.data()) { diff --git a/repos/base-linux/src/core/include/irq_object.h b/repos/base-linux/src/core/include/irq_object.h index e2fcb21f9..d50a49d41 100644 --- a/repos/base-linux/src/core/include/irq_object.h +++ b/repos/base-linux/src/core/include/irq_object.h @@ -27,8 +27,8 @@ class Genode::Irq_object : public Thread_deprecated<4096> private: Genode::Signal_context_capability _sig_cap; - Genode::Lock _sync_ack; - Genode::Lock _sync_bootup; + Genode::Blockade _sync_ack { }; + Genode::Blockade _sync_bootup { }; unsigned const _irq; int _fd; diff --git a/repos/base-linux/src/core/spec/linux/irq_session_component.cc b/repos/base-linux/src/core/spec/linux/irq_session_component.cc index 200bec0a3..20b653200 100644 --- a/repos/base-linux/src/core/spec/linux/irq_session_component.cc +++ b/repos/base-linux/src/core/spec/linux/irq_session_component.cc @@ -45,8 +45,6 @@ Genode::Irq_session::Info Genode::Irq_session_component::info() Genode::Irq_object::Irq_object(unsigned irq) : Thread_deprecated<4096>("irq"), _sig_cap(Signal_context_capability()), - _sync_ack(Lock::LOCKED), - _sync_bootup(Lock::LOCKED), _irq(irq), _fd(-1) { diff --git a/repos/base-linux/src/core/spec/pc/irq_session_component.cc b/repos/base-linux/src/core/spec/pc/irq_session_component.cc index 8d51cebb0..bfd0012d8 100644 --- a/repos/base-linux/src/core/spec/pc/irq_session_component.cc +++ b/repos/base-linux/src/core/spec/pc/irq_session_component.cc @@ -53,8 +53,6 @@ Genode::Irq_session::Info Genode::Irq_session_component::info() Genode::Irq_object::Irq_object(unsigned irq) : Thread_deprecated<4096>("irq"), _sig_cap(Signal_context_capability()), - _sync_ack(Lock::LOCKED), - _sync_bootup(Lock::LOCKED), _irq(irq), _fd(-1) { } @@ -82,8 +80,8 @@ void Genode::Irq_object::entry() error("failed to register IRQ ", _irq); } - _sync_bootup.unlock(); - _sync_ack.lock(); + _sync_bootup.wakeup(); + _sync_ack.block(); while (true) { @@ -97,19 +95,19 @@ void Genode::Irq_object::entry() Genode::Signal_transmitter(_sig_cap).submit(1); - _sync_ack.lock(); + _sync_ack.block(); } } void Genode::Irq_object::ack_irq() { - _sync_ack.unlock(); + _sync_ack.wakeup(); } void Genode::Irq_object::start() { Genode::Thread::start(); - _sync_bootup.lock(); + _sync_bootup.block(); } void Genode::Irq_object::sigh(Signal_context_capability cap) diff --git a/repos/base-linux/src/lib/base/thread_linux.cc b/repos/base-linux/src/lib/base/thread_linux.cc index 8c682bc8a..bd70ecb6e 100644 --- a/repos/base-linux/src/lib/base/thread_linux.cc +++ b/repos/base-linux/src/lib/base/thread_linux.cc @@ -36,10 +36,10 @@ extern int main_thread_futex_counter; static void empty_signal_handler(int) { } -static Lock &startup_lock() +static Blockade &startup_lock() { - static Lock lock(Lock::LOCKED); - return lock; + static Blockade blockade; + return blockade; } @@ -75,7 +75,7 @@ void Thread::_thread_start() } /* wakeup 'start' function */ - startup_lock().unlock(); + startup_lock().wakeup(); thread->entry(); @@ -140,8 +140,8 @@ void Thread::_deinit_platform_thread() void Thread::start() { /* synchronize calls of the 'start' function */ - static Lock lock; - Lock::Guard guard(lock); + static Mutex mutex; + Mutex::Guard guard(mutex); _init_cpu_session_and_trace_control(); @@ -161,7 +161,7 @@ void Thread::start() native_thread().pid = lx_getpid(); /* wait until the 'thread_start' function got entered */ - startup_lock().lock(); + startup_lock().block(); } diff --git a/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc b/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc index 6cfe12fad..7d8a7f4db 100644 --- a/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc +++ b/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc @@ -250,26 +250,21 @@ namespace Genode { { private: - /** - * Lock with the initial state set to LOCKED - */ - struct Barrier : Lock { Barrier() : Lock(Lock::LOCKED) { } }; - /** * Used to block the constructor until the new thread has initialized * 'id' */ - Barrier _construct_lock { }; + Blockade _construct_lock { }; /** * Used to block the new thread until 'start' is called */ - Barrier _start_lock { }; + Blockade _start_lock { }; /** * Used to block the 'join()' function until the 'entry()' is done */ - Barrier _join_lock { }; + Blockade _join_lock { }; public: @@ -278,32 +273,32 @@ namespace Genode { void wait_for_construction() override { - _construct_lock.lock(); + _construct_lock.block(); } void constructed() override { - _construct_lock.unlock(); + _construct_lock.wakeup(); } void wait_for_start() override { - _start_lock.lock(); + _start_lock.block(); } void started() override { - _start_lock.unlock(); + _start_lock.wakeup(); } void wait_for_join() override { - _join_lock.lock(); + _join_lock.block(); } void joined() override { - _join_lock.unlock(); + _join_lock.wakeup(); } }; diff --git a/repos/base-linux/src/test/lx_hybrid_errno/main.cc b/repos/base-linux/src/test/lx_hybrid_errno/main.cc index 2976dd89b..d2e4022b8 100644 --- a/repos/base-linux/src/test/lx_hybrid_errno/main.cc +++ b/repos/base-linux/src/test/lx_hybrid_errno/main.cc @@ -19,9 +19,9 @@ enum { STACK_SIZE = 4096 }; struct Thread : Genode::Thread_deprecated { - Genode::Lock &_barrier; + Genode::Blockade &_barrier; - Thread(Genode::Lock &barrier) + Thread(Genode::Blockade &barrier) : Genode::Thread_deprecated("stat"), _barrier(barrier) { start(); } void entry() override @@ -37,7 +37,7 @@ struct Thread : Genode::Thread_deprecated /* * Let main thread procees */ - _barrier.unlock(); + _barrier.wakeup(); } }; @@ -55,7 +55,7 @@ void Component::construct(Genode::Env &env) { Genode::log("--- thread-local errno test ---"); - static Genode::Lock barrier(Genode::Lock::LOCKED); + static Genode::Blockade barrier; int const orig_errno = errno; @@ -65,7 +65,7 @@ void Component::construct(Genode::Env &env) static Thread thread(barrier); /* block until the thread performed a 'stat' syscall */ - barrier.lock(); + barrier.block(); Genode::log("main: after thread completed, errno=", errno); diff --git a/repos/base-linux/src/test/lx_hybrid_pthread_ipc/main.cc b/repos/base-linux/src/test/lx_hybrid_pthread_ipc/main.cc index a2d198322..0b4f482c4 100644 --- a/repos/base-linux/src/test/lx_hybrid_pthread_ipc/main.cc +++ b/repos/base-linux/src/test/lx_hybrid_pthread_ipc/main.cc @@ -24,9 +24,9 @@ -static Genode::Lock *main_wait_lock() +static Genode::Blockade *main_wait_lock() { - static Genode::Lock inst(Genode::Lock::LOCKED); + static Genode::Blockade inst; return &inst; } @@ -46,7 +46,7 @@ static void *pthread_entry(void *) Genode::log("second message"); - main_wait_lock()->unlock(); + main_wait_lock()->wakeup(); return 0; } @@ -67,7 +67,7 @@ void Component::construct(Genode::Env &env) pthread_create(&pth, 0, pthread_entry, 0); /* wait until 'pthread_entry' finished */ - main_wait_lock()->lock(); + main_wait_lock()->block(); Genode::log("--- finished pthread IPC test ---"); exit_status = 0; diff --git a/repos/base-linux/src/timer/linux/time_source.cc b/repos/base-linux/src/timer/linux/time_source.cc index 4369c0a4f..d2e71d406 100644 --- a/repos/base-linux/src/timer/linux/time_source.cc +++ b/repos/base-linux/src/timer/linux/time_source.cc @@ -28,7 +28,7 @@ inline int lx_gettimeofday(struct timeval *tv, struct timeval *tz) { Microseconds Timer::Time_source::max_timeout() const { - Lock::Guard lock_guard(_lock); + Mutex::Guard mutex_guard(_mutex); return Microseconds(1000 * 1000); } diff --git a/repos/base-nova/include/nova/cap_map.h b/repos/base-nova/include/nova/cap_map.h index d87a93c63..a2d392771 100644 --- a/repos/base-nova/include/nova/cap_map.h +++ b/repos/base-nova/include/nova/cap_map.h @@ -21,7 +21,7 @@ /* Genode includes */ #include -#include +#include #include #include @@ -32,12 +32,12 @@ namespace Genode { private: - Lock _lock { }; + Mutex _mutex { }; addr_t _base = 0; addr_t _last = 0; enum { - HEADER = sizeof(_base) + sizeof(_lock) + sizeof(_last), + HEADER = sizeof(_base) + sizeof(_mutex) + sizeof(_last), CAP_RANGE_SIZE = 4096, WORDS = (CAP_RANGE_SIZE - HEADER - sizeof(Avl_node)) / sizeof(addr_t), }; diff --git a/repos/base-nova/src/core/include/pager.h b/repos/base-nova/src/core/include/pager.h index 90889d580..4167bc21b 100644 --- a/repos/base-nova/src/core/include/pager.h +++ b/repos/base-nova/src/core/include/pager.h @@ -78,7 +78,7 @@ namespace Genode { addr_t _initial_eip = 0; addr_t _client_exc_pt_sel; - Lock _state_lock { }; + Mutex _state_lock { }; struct { @@ -230,7 +230,7 @@ namespace Genode { */ bool copy_thread_state(Thread_state * state_dst) { - Lock::Guard _state_lock_guard(_state_lock); + Mutex::Guard _state_lock_guard(_state_lock); if (!state_dst || !_state.blocked()) return false; @@ -245,7 +245,7 @@ namespace Genode { */ bool copy_thread_state(Thread_state state_src) { - Lock::Guard _state_lock_guard(_state_lock); + Mutex::Guard _state_lock_guard(_state_lock); if (!_state.blocked()) return false; @@ -267,12 +267,12 @@ namespace Genode { inline void single_step(bool on) { - _state_lock.lock(); + _state_lock.acquire(); if (_state.is_dead() || !_state.blocked() || (on && (_state._status & _state.SINGLESTEP)) || (!on && !(_state._status & _state.SINGLESTEP))) { - _state_lock.unlock(); + _state_lock.release(); return; } @@ -281,7 +281,7 @@ namespace Genode { else _state._status &= ~_state.SINGLESTEP; - _state_lock.unlock(); + _state_lock.release(); /* force client in exit and thereby apply single_step change */ client_recall(false); diff --git a/repos/base-nova/src/core/include/rpc_cap_factory.h b/repos/base-nova/src/core/include/rpc_cap_factory.h index d3f0fb451..aa74debff 100644 --- a/repos/base-nova/src/core/include/rpc_cap_factory.h +++ b/repos/base-nova/src/core/include/rpc_cap_factory.h @@ -16,7 +16,7 @@ /* Genode includes */ #include -#include +#include #include #include #include @@ -40,7 +40,7 @@ class Genode::Rpc_cap_factory Tslab _slab; List _list { }; - Lock _lock { }; + Mutex _mutex { }; public: diff --git a/repos/base-nova/src/core/pager.cc b/repos/base-nova/src/core/pager.cc index 212a6fcfc..429017ed7 100644 --- a/repos/base-nova/src/core/pager.cc +++ b/repos/base-nova/src/core/pager.cc @@ -138,7 +138,7 @@ void Pager_object::_page_fault_handler(Pager_object &obj) * handler thread which may respond via wake_up() (ep thread) before * we are done here - we have to lock the whole page lookup procedure */ - obj._state_lock.lock(); + obj._state_lock.acquire(); obj._state.thread.ip = ipc_pager.fault_ip(); obj._state.thread.sp = 0; @@ -164,7 +164,7 @@ void Pager_object::_page_fault_handler(Pager_object &obj) if (res == Nova::NOVA_PD_OOM) { obj._state.unblock_pause_sm(); obj._state.unblock(); - obj._state_lock.unlock(); + obj._state_lock.release(); /* block until revoke is due */ ipc_pager.reply_and_wait_for_fault(obj.sel_sm_block_oom()); @@ -178,7 +178,7 @@ void Pager_object::_page_fault_handler(Pager_object &obj) if (!error) { obj._state.unblock_pause_sm(); obj._state.unblock(); - obj._state_lock.unlock(); + obj._state_lock.release(); ipc_pager.reply_and_wait_for_fault(); } @@ -196,7 +196,7 @@ void Pager_object::_page_fault_handler(Pager_object &obj) /* region manager fault - to be handled */ log("page fault, ", fault_info, " reason=", error); - obj._state_lock.unlock(); + obj._state_lock.release(); /* block the faulting thread until region manager is done */ ipc_pager.reply_and_wait_for_fault(obj.sel_sm_block_pause()); @@ -218,7 +218,7 @@ void Pager_object::exception(uint8_t exit_id) uint8_t res = 0xFF; addr_t mtd = 0; - _state_lock.lock(); + _state_lock.acquire(); /* remember exception type for Cpu_session::state() calls */ _state.thread.trapno = exit_id; @@ -254,7 +254,7 @@ void Pager_object::exception(uint8_t exit_id) } } - _state_lock.unlock(); + _state_lock.release(); utcb.set_msg_word(0); utcb.mtd = mtd; @@ -268,7 +268,7 @@ void Pager_object::_recall_handler(Pager_object &obj) Thread &myself = *Thread::myself(); Utcb &utcb = *reinterpret_cast(myself.utcb()); - obj._state_lock.lock(); + obj._state_lock.acquire(); if (obj._state.modified) { obj._copy_state_to_utcb(utcb); @@ -299,7 +299,7 @@ void Pager_object::_recall_handler(Pager_object &obj) obj._state.block_pause_sm(); } - obj._state_lock.unlock(); + obj._state_lock.release(); utcb.set_msg_word(0); reply(myself.stack_top(), sm); @@ -429,7 +429,7 @@ void Pager_object::_invoke_handler(Pager_object &obj) void Pager_object::wake_up() { - Lock::Guard _state_lock_guard(_state_lock); + Mutex::Guard _state_lock_guard(_state_lock); if (!_state.blocked()) return; @@ -467,7 +467,7 @@ void Pager_object::client_cancel_blocking() uint8_t Pager_object::client_recall(bool get_state_and_block) { - Lock::Guard _state_lock_guard(_state_lock); + Mutex::Guard _state_lock_guard(_state_lock); return _unsynchronized_client_recall(get_state_and_block); } diff --git a/repos/base-nova/src/core/rpc_cap_factory.cc b/repos/base-nova/src/core/rpc_cap_factory.cc index a2fdb4d0c..d929b7aac 100644 --- a/repos/base-nova/src/core/rpc_cap_factory.cc +++ b/repos/base-nova/src/core/rpc_cap_factory.cc @@ -29,7 +29,7 @@ Native_capability Rpc_cap_factory::alloc(Native_capability ep, addr_t entry, add using namespace Nova; - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); /* create cap object */ Cap_object * pt_cap = new (&_slab) Cap_object(pt_sel); @@ -64,7 +64,7 @@ void Rpc_cap_factory::free(Native_capability cap) { if (!cap.valid()) return; - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); for (Cap_object *obj = _list.first(); obj ; obj = obj->next()) { if (cap.local_name() == (long)obj->_cap_sel) { @@ -86,7 +86,7 @@ Rpc_cap_factory::Rpc_cap_factory(Allocator &md_alloc) Rpc_cap_factory::~Rpc_cap_factory() { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); for (Cap_object *obj; (obj = _list.first()); ) { Nova::revoke(Nova::Obj_crd(obj->_cap_sel, 0)); diff --git a/repos/base-nova/src/lib/base/cap_map.cc b/repos/base-nova/src/lib/base/cap_map.cc index 82c0a8add..0e2044fba 100644 --- a/repos/base-nova/src/lib/base/cap_map.cc +++ b/repos/base-nova/src/lib/base/cap_map.cc @@ -46,7 +46,7 @@ void Cap_range::inc(unsigned id) { bool failure = false; { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); if (_cap_array[id] + 1 == 0) failure = true; @@ -65,7 +65,7 @@ void Cap_range::dec(unsigned const id_start, bool revoke, unsigned num_log_2) { unsigned const end = min(id_start + (1U << num_log_2), elements()); - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); for (unsigned id = id_start; id < end; id++) { if (_cap_array[id] == 0) { @@ -92,7 +92,7 @@ addr_t Cap_range::alloc(size_t const num_log2) addr_t const step = 1UL << num_log2; { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); unsigned max = elements(); addr_t last = _last; diff --git a/repos/base-okl4/src/core/irq_session_component.cc b/repos/base-okl4/src/core/irq_session_component.cc index 698db4833..807b6bc5f 100644 --- a/repos/base-okl4/src/core/irq_session_component.cc +++ b/repos/base-okl4/src/core/irq_session_component.cc @@ -83,7 +83,7 @@ void Irq_object::_wait_for_irq() void Irq_object::start() { ::Thread::start(); - _sync_bootup.lock(); + _sync_bootup.block(); } @@ -93,10 +93,10 @@ void Irq_object::entry() error("could not associate with IRQ ", Hex(_irq)); /* thread is up and ready */ - _sync_bootup.unlock(); + _sync_bootup.wakeup(); /* wait for first ack_irq */ - _sync_ack.lock(); + _sync_ack.block(); while (true) { @@ -110,7 +110,7 @@ void Irq_object::entry() Genode::Signal_transmitter(_sig_cap).submit(1); - _sync_ack.lock(); + _sync_ack.block(); } } @@ -118,7 +118,6 @@ void Irq_object::entry() Irq_object::Irq_object(unsigned irq) : Thread_deprecated<4096>("irq"), - _sync_ack(Lock::LOCKED), _sync_bootup(Lock::LOCKED), _irq(irq) { } diff --git a/repos/base-pistachio/src/core/irq_session_component.cc b/repos/base-pistachio/src/core/irq_session_component.cc index 6e17e70b8..08c1e2de1 100644 --- a/repos/base-pistachio/src/core/irq_session_component.cc +++ b/repos/base-pistachio/src/core/irq_session_component.cc @@ -61,7 +61,7 @@ void Irq_object::_wait_for_irq() void Irq_object::start() { ::Thread::start(); - _sync_bootup.lock(); + _sync_bootup.block(); } @@ -73,10 +73,10 @@ void Irq_object::entry() } /* thread is up and ready */ - _sync_bootup.unlock(); + _sync_bootup.wakeup(); /* wait for first ack_irq */ - _sync_ack.lock(); + _sync_ack.block(); /* * Right after associating with an interrupt, the interrupt is @@ -96,7 +96,7 @@ void Irq_object::entry() */ if (_sig_cap.valid()) { Genode::Signal_transmitter(_sig_cap).submit(1); - _sync_ack.lock(); + _sync_ack.block(); } while (true) { @@ -108,7 +108,7 @@ void Irq_object::entry() Genode::Signal_transmitter(_sig_cap).submit(1); - _sync_ack.lock(); + _sync_ack.block(); } } @@ -116,7 +116,6 @@ void Irq_object::entry() Irq_object::Irq_object(unsigned irq) : Thread_deprecated<4096>("irq"), - _sync_ack(Lock::LOCKED), _sync_bootup(Lock::LOCKED), _irq(irq) { } diff --git a/repos/base-sel4/src/core/include/irq_object.h b/repos/base-sel4/src/core/include/irq_object.h index e20883f50..839819a6c 100644 --- a/repos/base-sel4/src/core/include/irq_object.h +++ b/repos/base-sel4/src/core/include/irq_object.h @@ -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; diff --git a/repos/base-sel4/src/core/include/platform.h b/repos/base-sel4/src/core/include/platform.h index acd250f26..327bf485b 100644 --- a/repos/base-sel4/src/core/include/platform.h +++ b/repos/base-sel4/src/core/include/platform.h @@ -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()); } diff --git a/repos/base-sel4/src/core/include/platform_pd.h b/repos/base-sel4/src/core/include/platform_pd.h index bc2ae8044..2eb105360 100644 --- a/repos/base-sel4/src/core/include/platform_pd.h +++ b/repos/base-sel4/src/core/include/platform_pd.h @@ -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); diff --git a/repos/base-sel4/src/core/include/vm_space.h b/repos/base-sel4/src/core/include/vm_space.h index c8dc95955..884ee6af9 100644 --- a/repos/base-sel4/src/core/include/vm_space.h +++ b/repos/base-sel4/src/core/include/vm_space.h @@ -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); } diff --git a/repos/base-sel4/src/core/irq_session_component.cc b/repos/base-sel4/src/core/irq_session_component.cc index 9608b4f4b..90efcdd07 100644 --- a/repos/base-sel4/src/core/irq_session_component.cc +++ b/repos/base-sel4/src/core/irq_session_component.cc @@ -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()) diff --git a/repos/base-sel4/src/core/platform_pd.cc b/repos/base-sel4/src/core/platform_pd.cc index df4a068ad..29fa7a307 100644 --- a/repos/base-sel4/src/core/platform_pd.cc +++ b/repos/base-sel4/src/core/platform_pd.cc @@ -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()); } diff --git a/repos/base-sel4/src/core/platform_thread.cc b/repos/base-sel4/src/core/platform_thread.cc index c5d263130..b9cd77d15 100644 --- a/repos/base-sel4/src/core/platform_thread.cc +++ b/repos/base-sel4/src/core/platform_thread.cc @@ -38,19 +38,19 @@ class Platform_thread_registry : Noncopyable private: List _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) { diff --git a/repos/base-sel4/src/include/base/internal/capability_space_sel4.h b/repos/base-sel4/src/include/base/internal/capability_space_sel4.h index c81ada238..4f9678596 100644 --- a/repos/base-sel4/src/include/base/internal/capability_space_sel4.h +++ b/repos/base-sel4/src/include/base/internal/capability_space_sel4.h @@ -15,8 +15,8 @@ #define _INCLUDE__BASE__INTERNAL__CAPABILITY_SPACE_SEL4_H_ /* base includes */ +#include #include -#include #include /* base-internal includes */ @@ -171,7 +171,7 @@ class Genode::Capability_space_sel4 Tree_managed_data _caps_data[NUM_CAPS]; Avl_tree _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(&_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; diff --git a/repos/base-sel4/src/lib/base/capability_space.cc b/repos/base-sel4/src/lib/base/capability_space.cc index dc0c12698..f63f50881 100644 --- a/repos/base-sel4/src/lib/base/capability_space.cc +++ b/repos/base-sel4/src/lib/base/capability_space.cc @@ -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); } }; diff --git a/repos/base-sel4/src/lib/base/x86/vm_session.cc b/repos/base-sel4/src/lib/base/x86/vm_session.cc index 5d7155404..1ec704145 100644 --- a/repos/base-sel4/src/lib/base/x86/vm_session.cc +++ b/repos/base-sel4/src/lib/base/x86/vm_session.cc @@ -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; diff --git a/repos/base/src/core/cpu_session_component.cc b/repos/base/src/core/cpu_session_component.cc index 2ea820937..f34b8399c 100644 --- a/repos/base/src/core/cpu_session_component.cc +++ b/repos/base/src/core/cpu_session_component.cc @@ -49,7 +49,7 @@ Thread_capability Cpu_session_component::create_thread(Capability pd weight = Weight(QUOTA_LIMIT); } - Lock::Guard thread_list_lock_guard(_thread_list_lock); + Mutex::Guard thread_list_lock_guard(_thread_list_lock); /* * Create thread associated with its protection domain @@ -60,7 +60,7 @@ Thread_capability Cpu_session_component::create_thread(Capability pd throw Thread_creation_failed(); } - Lock::Guard slab_lock_guard(_thread_alloc_lock); + Mutex::Guard slab_lock_guard(_thread_alloc_lock); thread = new (&_thread_alloc) Cpu_thread_component( cap(), _thread_ep, _pager_ep, *pd, _trace_control_area, @@ -122,7 +122,7 @@ void Cpu_session_component::_unsynchronized_kill_thread(Thread_capability thread _decr_weight(thread->weight()); { - Lock::Guard lock_guard(_thread_alloc_lock); + Mutex::Guard lock_guard(_thread_alloc_lock); destroy(&_thread_alloc, thread); } @@ -135,7 +135,7 @@ void Cpu_session_component::kill_thread(Thread_capability thread_cap) if (!thread_cap.valid()) return; - Lock::Guard lock_guard(_thread_list_lock); + Mutex::Guard lock_guard(_thread_list_lock); /* check that cap belongs to this session */ for (Cpu_thread_component *t = _thread_list.first(); t; t = t->next()) { @@ -151,7 +151,7 @@ void Cpu_session_component::exception_sigh(Signal_context_capability sigh) { _exception_sigh = sigh; - Lock::Guard lock_guard(_thread_list_lock); + Mutex::Guard lock_guard(_thread_list_lock); for (Cpu_thread_component *t = _thread_list.first(); t; t = t->next()) t->session_exception_sigh(_exception_sigh); @@ -300,7 +300,7 @@ void Cpu_session_component::_deinit_ref_account() { /* rewire child ref accounts to this sessions's ref account */ { - Lock::Guard lock_guard(_ref_members_lock); + Mutex::Guard lock_guard(_ref_members_lock); for (Cpu_session_component * s; (s = _ref_members.first()); ) { _unsync_remove_ref_member(*s); if (_ref) @@ -320,7 +320,7 @@ void Cpu_session_component::_deinit_ref_account() void Cpu_session_component::_deinit_threads() { - Lock::Guard lock_guard(_thread_list_lock); + Mutex::Guard lock_guard(_thread_list_lock); /* * We have to keep the '_thread_list_lock' during the whole destructor to @@ -356,7 +356,7 @@ void Cpu_session_component::_decr_weight(size_t const weight) void Cpu_session_component::_decr_quota(size_t const quota) { - Lock::Guard lock_guard(_thread_list_lock); + Mutex::Guard lock_guard(_thread_list_lock); _quota -= quota; _update_each_thread_quota(); } @@ -364,7 +364,7 @@ void Cpu_session_component::_decr_quota(size_t const quota) void Cpu_session_component::_incr_quota(size_t const quota) { - Lock::Guard lock_guard(_thread_list_lock); + Mutex::Guard lock_guard(_thread_list_lock); _quota += quota; _update_each_thread_quota(); } @@ -391,9 +391,9 @@ size_t Cpu_session_component::_weight_to_quota(size_t const weight) const unsigned Trace::Source::_alloc_unique_id() { - static Lock lock; + static Mutex lock; static unsigned cnt; - Lock::Guard guard(lock); + Mutex::Guard guard(lock); return cnt++; } diff --git a/repos/base/src/core/dataspace_component.cc b/repos/base/src/core/dataspace_component.cc index ed19e743d..1ba4f5ead 100644 --- a/repos/base/src/core/dataspace_component.cc +++ b/repos/base/src/core/dataspace_component.cc @@ -20,20 +20,20 @@ using namespace Genode; void Dataspace_component::attached_to(Rm_region ®ion) { - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); _regions.insert(®ion); } void Dataspace_component::detached_from(Rm_region ®ion) { - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); _regions.remove(®ion); } void Dataspace_component::detach_from_rm_sessions() { - _lock.lock(); + _mutex.acquire(); /* remove from all regions */ while (Rm_region *r = _regions.first()) { @@ -42,12 +42,12 @@ void Dataspace_component::detach_from_rm_sessions() * The 'detach' function calls 'Dataspace_component::detached_from' * and thereby removes the current region from the '_regions' list. */ - _lock.unlock(); + _mutex.release(); r->rm().detach((void *)r->base()); - _lock.lock(); + _mutex.acquire(); } - _lock.unlock(); + _mutex.release(); } Dataspace_component::~Dataspace_component() diff --git a/repos/base/src/core/include/account.h b/repos/base/src/core/include/account.h index db4eea188..fda6370ad 100644 --- a/repos/base/src/core/include/account.h +++ b/repos/base/src/core/include/account.h @@ -56,7 +56,7 @@ class Genode::Account return UNIT { _quota_guard.limit().value - _initial_limit.value }; } - Lock mutable _lock { }; + Mutex mutable _mutex { }; /* * Reference account @@ -112,7 +112,7 @@ class Genode::Account { if (!_ref_account) return; - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); if (_quota_guard.used().value > _initial_used.value) { UNIT const dangling { _quota_guard.used().value - _initial_used.value }; @@ -139,7 +139,7 @@ class Genode::Account void transfer_quota(Account &other, UNIT amount) { { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); /* transfers are permitted only from/to the reference account */ if (_ref_account != &other && other._ref_account != this) @@ -155,25 +155,25 @@ class Genode::Account } /* credit to 'other' */ - Lock::Guard guard(other._lock); + Mutex::Guard guard(other._mutex); other._quota_guard.upgrade(amount); } UNIT limit() const { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); return _quota_guard.limit(); } UNIT used() const { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); return _quota_guard.used(); } UNIT avail() const { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); return _quota_guard.avail(); } @@ -186,7 +186,7 @@ class Genode::Account */ void withdraw(UNIT amount) { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); _quota_guard.withdraw(amount); } @@ -197,7 +197,7 @@ class Genode::Account */ void replenish(UNIT amount) { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); _quota_guard.replenish(amount); } diff --git a/repos/base/src/core/include/cpu_session_component.h b/repos/base/src/core/include/cpu_session_component.h index c8e959686..fb9f05e1a 100644 --- a/repos/base/src/core/include/cpu_session_component.h +++ b/repos/base/src/core/include/cpu_session_component.h @@ -17,7 +17,7 @@ /* Genode includes */ #include #include -#include +#include #include #include #include @@ -46,9 +46,9 @@ class Genode::Cpu_session_component : public Rpc_object, Pager_entrypoint &_pager_ep; Allocator_guard _md_alloc; /* guarded meta-data allocator */ Cpu_thread_allocator _thread_alloc; /* meta-data allocator */ - Lock _thread_alloc_lock { }; /* protect allocator access */ + Mutex _thread_alloc_lock { }; /* protect allocator access */ List _thread_list { }; - Lock _thread_list_lock { }; /* protect thread list */ + Mutex _thread_list_lock { }; /* protect thread list */ unsigned _priority; /* priority of threads created with this session */ @@ -65,7 +65,7 @@ class Genode::Cpu_session_component : public Rpc_object, size_t _quota { 0 }; Cpu_session_component * _ref { nullptr }; List _ref_members { }; - Lock _ref_members_lock { }; + Mutex _ref_members_lock { }; Native_cpu_component _native_cpu; @@ -87,7 +87,7 @@ class Genode::Cpu_session_component : public Rpc_object, void _insert_ref_member(Cpu_session_component * const s) { - Lock::Guard lock_guard(_ref_members_lock); + Mutex::Guard lock_guard(_ref_members_lock); _ref_members.insert(s); s->_ref = this; } @@ -100,7 +100,7 @@ class Genode::Cpu_session_component : public Rpc_object, void _remove_ref_member(Cpu_session_component &s) { - Lock::Guard lock_guard(_ref_members_lock); + Mutex::Guard lock_guard(_ref_members_lock); _unsync_remove_ref_member(s); } @@ -117,7 +117,7 @@ class Genode::Cpu_session_component : public Rpc_object, * Raw thread-killing functionality * * This function is called from the 'kill_thread' function and - * the destructor. Each these functions grab the list lock + * the destructor. Each these functions grab the list mutex * by themselves and call this function to perform the actual * killing. */ diff --git a/repos/base/src/core/include/dataspace_component.h b/repos/base/src/core/include/dataspace_component.h index 5f4c94cec..f25e954e2 100644 --- a/repos/base/src/core/include/dataspace_component.h +++ b/repos/base/src/core/include/dataspace_component.h @@ -16,7 +16,7 @@ #define _CORE__INCLUDE__DATASPACE_COMPONENT_H_ /* Genode includes */ -#include +#include #include #include @@ -48,7 +48,7 @@ namespace Genode { Cache_attribute const _cache { CACHED }; List _regions { }; /* regions this is attached to */ - Lock _lock { }; + Mutex _mutex { }; /* * Holds the dataspace owner if a distinction between owner and diff --git a/repos/base/src/core/include/irq_object.h b/repos/base/src/core/include/irq_object.h index bc5f55358..b1ef853cb 100644 --- a/repos/base/src/core/include/irq_object.h +++ b/repos/base/src/core/include/irq_object.h @@ -23,8 +23,8 @@ class Genode::Irq_object : public Thread_deprecated<4096> { private: Signal_context_capability _sig_cap { }; - Lock _sync_ack; - Lock _sync_bootup; + Blockade _sync_ack { }; + Blockade _sync_bootup { }; unsigned _irq; bool _associate(); @@ -37,7 +37,7 @@ class Genode::Irq_object : public Thread_deprecated<4096> { Irq_object(unsigned irq); void sigh(Signal_context_capability cap) { _sig_cap = cap; } - void ack_irq() { _sync_ack.unlock(); } + void ack_irq() { _sync_ack.wakeup(); } void start() override; }; diff --git a/repos/base/src/core/include/region_map_component.h b/repos/base/src/core/include/region_map_component.h index 49481293f..b05f37c70 100644 --- a/repos/base/src/core/include/region_map_component.h +++ b/repos/base/src/core/include/region_map_component.h @@ -17,7 +17,7 @@ /* Genode includes */ #include -#include +#include #include #include #include @@ -123,7 +123,7 @@ class Genode::Rm_faulter : Fifo::Element, Interface private: Pager_object &_pager_object; - Lock _lock { }; + Mutex _mutex { }; Weak_ptr _faulting_region_map { }; Region_map::State _fault_state { }; @@ -304,7 +304,7 @@ class Genode::Region_map_component : private Weak_object, the region map and wait for fault resolution */ List _clients { }; /* list of RM clients using this region map */ - Lock _lock { }; /* lock for map and list */ + Mutex _mutex { }; /* mutex for map and list */ Pager_entrypoint &_pager_ep; Rm_dataspace_component _ds; /* dataspace representation of region map */ Dataspace_capability _ds_cap; @@ -317,7 +317,7 @@ class Genode::Region_map_component : private Weak_object, using Functor = Trait::Functor; using Return_type = typename Functor::Return_type; - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); /* skip further lookup when reaching the recursion limit */ if (!level) return f(this, nullptr, 0, 0, dst_region_size); diff --git a/repos/base/src/core/include/rm_session_component.h b/repos/base/src/core/include/rm_session_component.h index be9ef0cc1..9e74d0add 100644 --- a/repos/base/src/core/include/rm_session_component.h +++ b/repos/base/src/core/include/rm_session_component.h @@ -33,7 +33,7 @@ class Genode::Rm_session_component : public Rpc_object Allocator_guard _md_alloc; Pager_entrypoint &_pager_ep; - Lock _region_maps_lock { }; + Mutex _region_maps_lock { }; List _region_maps { }; public: @@ -51,7 +51,7 @@ class Genode::Rm_session_component : public Rpc_object ~Rm_session_component() { - Lock::Guard guard(_region_maps_lock); + Mutex::Guard guard(_region_maps_lock); while (Region_map_component *rmc = _region_maps.first()) { _region_maps.remove(rmc); @@ -71,7 +71,7 @@ class Genode::Rm_session_component : public Rpc_object Capability create(size_t size) override { - Lock::Guard guard(_region_maps_lock); + Mutex::Guard guard(_region_maps_lock); try { Region_map_component *rm = @@ -88,7 +88,7 @@ class Genode::Rm_session_component : public Rpc_object void destroy(Capability cap) override { - Lock::Guard guard(_region_maps_lock); + Mutex::Guard guard(_region_maps_lock); Region_map_component *rm = nullptr; diff --git a/repos/base/src/core/include/rpc_cap_factory.h b/repos/base/src/core/include/rpc_cap_factory.h index ccced33d2..348bd7d54 100644 --- a/repos/base/src/core/include/rpc_cap_factory.h +++ b/repos/base/src/core/include/rpc_cap_factory.h @@ -15,8 +15,8 @@ #define _CORE__INCLUDE__RPC_CAP_FACTORY_H_ #include -#include #include +#include namespace Genode { class Rpc_cap_factory; } @@ -25,7 +25,7 @@ class Genode::Rpc_cap_factory private: static long _unique_id_cnt; - static Lock &_lock(); + static Mutex &_mutex(); public: @@ -33,7 +33,7 @@ class Genode::Rpc_cap_factory Native_capability alloc(Native_capability ep) { - Lock::Guard lock_guard(_lock()); + Mutex::Guard lock_guard(_mutex()); return Native_capability(ep.dst(), ++_unique_id_cnt); } diff --git a/repos/base/src/core/include/synced_ram_allocator.h b/repos/base/src/core/include/synced_ram_allocator.h index ebc7a8565..67aa345d2 100644 --- a/repos/base/src/core/include/synced_ram_allocator.h +++ b/repos/base/src/core/include/synced_ram_allocator.h @@ -16,7 +16,7 @@ /* Genode includes */ #include -#include +#include namespace Genode { class Synced_ram_allocator; } @@ -25,7 +25,7 @@ class Genode::Synced_ram_allocator : public Ram_allocator { private: - Lock mutable _lock { }; + Mutex mutable _mutex { }; Ram_allocator &_alloc; @@ -35,19 +35,19 @@ class Genode::Synced_ram_allocator : public Ram_allocator Ram_dataspace_capability alloc(size_t size, Cache_attribute cached) override { - Lock::Guard lock_guard(_lock); + Mutex::Guard mutex_guard(_mutex); return _alloc.alloc(size, cached); } void free(Ram_dataspace_capability ds) override { - Lock::Guard lock_guard(_lock); + Mutex::Guard mutex_guard(_mutex); _alloc.free(ds); } size_t dataspace_size(Ram_dataspace_capability ds) const override { - Lock::Guard lock_guard(_lock); + Mutex::Guard mutex_guard(_mutex); return _alloc.dataspace_size(ds); } }; diff --git a/repos/base/src/core/include/trace/policy_registry.h b/repos/base/src/core/include/trace/policy_registry.h index 79ded6255..53ab02192 100644 --- a/repos/base/src/core/include/trace/policy_registry.h +++ b/repos/base/src/core/include/trace/policy_registry.h @@ -15,7 +15,7 @@ #define _CORE__INCLUDE__TRACE__POLICY_REGISTRY_H_ /* Genode includes */ -#include +#include #include namespace Genode { namespace Trace { @@ -75,7 +75,7 @@ class Genode::Trace::Policy_registry private: - Lock _lock { }; + Mutex _mutex { }; List _policies { }; Policy &_unsynchronized_lookup(Policy_owner const &owner, Policy_id id) @@ -100,7 +100,7 @@ class Genode::Trace::Policy_registry ~Policy_registry() { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); while (Policy *p = _policies.first()) _policies.remove(p); @@ -109,7 +109,7 @@ class Genode::Trace::Policy_registry void insert(Policy_owner const &owner, Policy_id const id, Allocator &md_alloc, Dataspace_capability ds, size_t size) { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); Policy &policy = *new (&md_alloc) Policy(owner, id, md_alloc, ds, size); _policies.insert(&policy); @@ -117,7 +117,7 @@ class Genode::Trace::Policy_registry void remove(Policy_owner &owner, Policy_id id) { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); for (Policy *p = _policies.first(); p; ) { Policy *tmp = p; @@ -132,7 +132,7 @@ class Genode::Trace::Policy_registry void destroy_policies_owned_by(Policy_owner const &owner) { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); while (Policy *p = _any_policy_owned_by(owner)) { _policies.remove(p); @@ -142,14 +142,14 @@ class Genode::Trace::Policy_registry Dataspace_capability dataspace(Policy_owner &owner, Policy_id id) { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); return _unsynchronized_lookup(owner, id).dataspace(); } size_t size(Policy_owner &owner, Policy_id id) { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); return _unsynchronized_lookup(owner, id).size(); } diff --git a/repos/base/src/core/include/trace/source_registry.h b/repos/base/src/core/include/trace/source_registry.h index 9c3bb4ba1..900b9e16c 100644 --- a/repos/base/src/core/include/trace/source_registry.h +++ b/repos/base/src/core/include/trace/source_registry.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include @@ -152,7 +152,7 @@ class Genode::Trace::Source_registry { private: - Lock _lock { }; + Mutex _mutex { }; List _entries { }; public: @@ -163,14 +163,14 @@ class Genode::Trace::Source_registry void insert(Source *entry) { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); _entries.insert(entry); } void remove(Source *entry) { - Lock::Guard guard(_lock); + Mutex::Guard guard(_mutex); _entries.remove(entry); } diff --git a/repos/base/src/core/include/trace/subject_registry.h b/repos/base/src/core/include/trace/subject_registry.h index 75e872d93..6d7c0fb37 100644 --- a/repos/base/src/core/include/trace/subject_registry.h +++ b/repos/base/src/core/include/trace/subject_registry.h @@ -22,7 +22,7 @@ /* Genode includes */ #include #include -#include +#include #include #include #include @@ -312,7 +312,7 @@ class Genode::Trace::Subject_registry Ram_allocator &_ram; Source_registry &_sources; unsigned _id_cnt { 0 }; - Lock _lock { }; + Mutex _mutex { }; Subjects _entries { }; /** @@ -407,7 +407,7 @@ class Genode::Trace::Subject_registry */ ~Subject_registry() { - Lock guard(_lock); + Mutex::Guard guard(_mutex); while (Subject *s = _entries.first()) _unsynchronized_destroy(*s); @@ -418,7 +418,7 @@ class Genode::Trace::Subject_registry */ void import_new_sources(Source_registry &) { - Lock guard(_lock); + Mutex::Guard guard(_mutex); _sources.export_sources(_tester, _inserter); } @@ -428,7 +428,7 @@ class Genode::Trace::Subject_registry */ size_t subjects(Subject_id *dst, size_t dst_len) { - Lock guard(_lock); + Mutex::Guard guard(_mutex); unsigned i = 0; for (Subject *s = _entries.first(); s && i < dst_len; s = s->next()) @@ -446,7 +446,7 @@ class Genode::Trace::Subject_registry */ size_t release(Subject_id subject_id) { - Lock guard(_lock); + Mutex::Guard guard(_mutex); Subject &subject = _unsynchronized_lookup_by_id(subject_id); return _unsynchronized_destroy(subject); @@ -454,7 +454,7 @@ class Genode::Trace::Subject_registry Subject &lookup_by_id(Subject_id id) { - Lock guard(_lock); + Mutex::Guard guard(_mutex); return _unsynchronized_lookup_by_id(id); } diff --git a/repos/base/src/core/region_map_component.cc b/repos/base/src/core/region_map_component.cc index 35ed1cfbc..58784d500 100644 --- a/repos/base/src/core/region_map_component.cc +++ b/repos/base/src/core/region_map_component.cc @@ -15,7 +15,6 @@ /* Genode includes */ #include -#include #include #include @@ -270,7 +269,7 @@ int Rm_client::pager(Ipc_pager &pager) void Rm_faulter::fault(Region_map_component &faulting_region_map, Region_map::State fault_state) { - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); _faulting_region_map = faulting_region_map.weak_ptr(); _fault_state = fault_state; @@ -282,7 +281,7 @@ void Rm_faulter::fault(Region_map_component &faulting_region_map, void Rm_faulter::dissolve_from_faulting_region_map(Region_map_component &caller) { /* serialize access */ - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); enum { DO_LOCK = true }; if (caller.equals(_faulting_region_map)) { @@ -300,7 +299,7 @@ void Rm_faulter::dissolve_from_faulting_region_map(Region_map_component &caller) void Rm_faulter::continue_after_resolved_fault() { - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); _pager_object.wake_up(); _faulting_region_map = Genode::Weak_ptr(); @@ -355,7 +354,7 @@ Region_map_component::attach(Dataspace_capability ds_cap, size_t size, bool executable, bool writeable) { /* serialize access */ - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); /* offset must be positive and page-aligned */ if (offset < 0 || align_addr(offset, get_page_size_log2()) != offset) @@ -520,7 +519,7 @@ void Region_map_component::unmap_region(addr_t base, size_t size) void Region_map_component::detach(Local_addr local_addr) { /* serialize access */ - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); /* read meta data for address */ Rm_region *region_ptr = _map.metadata(local_addr); @@ -579,7 +578,7 @@ void Region_map_component::detach(Local_addr local_addr) void Region_map_component::add_client(Rm_client &rm_client) { - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); _clients.insert(&rm_client); } @@ -587,7 +586,7 @@ void Region_map_component::add_client(Rm_client &rm_client) void Region_map_component::remove_client(Rm_client &rm_client) { - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); _clients.remove(&rm_client); rm_client.dissolve_from_faulting_region_map(*this); @@ -611,7 +610,7 @@ void Region_map_component::fault(Rm_faulter &faulter, addr_t pf_addr, void Region_map_component::discard_faulter(Rm_faulter &faulter, bool do_lock) { if (do_lock) { - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); _faulters.remove(faulter); } else _faulters.remove(faulter); @@ -627,7 +626,7 @@ void Region_map_component::fault_handler(Signal_context_capability handler) Region_map::State Region_map_component::state() { /* serialize access */ - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); /* return ready state if there are not current faulters */ Region_map::State result; @@ -683,7 +682,7 @@ Region_map_component::~Region_map_component() Cpu_session_capability cpu_session_cap; Thread_capability thread_cap; { - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); cl = _clients.first(); if (!cl) break; @@ -708,7 +707,7 @@ Region_map_component::~Region_map_component() addr_t out_addr = 0; { - Lock::Guard lock_guard(_lock); + Mutex::Guard lock_guard(_mutex); if (!_map.any_block_addr(&out_addr)) break; } diff --git a/repos/base/src/core/rpc_cap_factory.cc b/repos/base/src/core/rpc_cap_factory.cc index 2f4c2e3b9..30100f905 100644 --- a/repos/base/src/core/rpc_cap_factory.cc +++ b/repos/base/src/core/rpc_cap_factory.cc @@ -16,8 +16,8 @@ long Genode::Rpc_cap_factory::_unique_id_cnt; -Genode::Lock &Genode::Rpc_cap_factory::_lock() +Genode::Mutex &Genode::Rpc_cap_factory::_mutex() { - static Lock static_lock; - return static_lock; + static Mutex static_mutex; + return static_mutex; }