From 997a77b3de3474f85bb31802f4f1a9c5bbc51148 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Tue, 7 Jul 2020 13:49:01 +0200 Subject: [PATCH] foc: use Mutex Issue #3809 --- repos/base-foc/include/foc/thread_state.h | 1 - .../src/core/include/pager_object_exception_state.h | 3 ++- repos/base-foc/src/core/pager.cc | 6 +++--- repos/base-foc/src/core/platform_thread.cc | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/repos/base-foc/include/foc/thread_state.h b/repos/base-foc/include/foc/thread_state.h index 5f9a860fd..dec92454f 100644 --- a/repos/base-foc/include/foc/thread_state.h +++ b/repos/base-foc/include/foc/thread_state.h @@ -17,7 +17,6 @@ #define _INCLUDE__FOC__THREAD_STATE_H_ #include -#include #include /* Fiasco includes */ diff --git a/repos/base-foc/src/core/include/pager_object_exception_state.h b/repos/base-foc/src/core/include/pager_object_exception_state.h index df21d9b3e..dd86cd1a1 100644 --- a/repos/base-foc/src/core/include/pager_object_exception_state.h +++ b/repos/base-foc/src/core/include/pager_object_exception_state.h @@ -14,13 +14,14 @@ #ifndef _CORE__INCLUDE__PAGER_OBJECT_EXCEPTION_STATE_H_ #define _CORE__INCLUDE__PAGER_OBJECT_EXCEPTION_STATE_H_ +#include #include namespace Genode { struct Pager_object_exception_state; } struct Genode::Pager_object_exception_state { - Lock lock { }; + Mutex mutex { }; unsigned exceptions; /* counts exceptions raised by the thread */ bool paused; /* indicates whether thread is stopped */ bool in_exception; /* true if thread is in exception */ diff --git a/repos/base-foc/src/core/pager.cc b/repos/base-foc/src/core/pager.cc index 439d16fe8..8c2f56f01 100644 --- a/repos/base-foc/src/core/pager.cc +++ b/repos/base-foc/src/core/pager.cc @@ -57,7 +57,7 @@ void Pager_entrypoint::entry() case Ipc_pager::EXCEPTION: { if (_pager.exception()) { - Lock::Guard guard(obj->state.lock); + Mutex::Guard guard(obj->state.mutex); _pager.get_regs(obj->state.state); obj->state.exceptions++; obj->state.in_exception = true; @@ -94,7 +94,7 @@ void Pager_entrypoint::entry() _pager.acknowledge_wakeup(); { - Lock::Guard guard(obj->state.lock); + Mutex::Guard guard(obj->state.mutex); /* revert exception flag */ obj->state.in_exception = false; /* set new register contents */ @@ -113,7 +113,7 @@ void Pager_entrypoint::entry() */ case Ipc_pager::PAUSE: { - Lock::Guard guard(obj->state.lock); + Mutex::Guard guard(obj->state.mutex); _pager.get_regs(obj->state.state); obj->state.exceptions++; obj->state.in_exception = true; diff --git a/repos/base-foc/src/core/platform_thread.cc b/repos/base-foc/src/core/platform_thread.cc index d7f3227b0..388405e41 100644 --- a/repos/base-foc/src/core/platform_thread.cc +++ b/repos/base-foc/src/core/platform_thread.cc @@ -89,10 +89,10 @@ void Platform_thread::pause() if (!_pager_obj) return; - _pager_obj->state.lock.lock(); + _pager_obj->state.mutex.acquire(); if (_pager_obj->state.paused == true) { - _pager_obj->state.lock.unlock(); + _pager_obj->state.mutex.release(); return; } @@ -118,7 +118,7 @@ void Platform_thread::pause() * The thread state ("ready") is encoded in the lowest bit of the flags. */ bool in_syscall = (flags & 1) == 0; - _pager_obj->state.lock.unlock(); + _pager_obj->state.mutex.release(); /** * Check whether the thread was in ongoing ipc, if so it won't raise @@ -151,11 +151,11 @@ void Platform_thread::resume() if (!_pager_obj) return; - _pager_obj->state.lock.lock(); + _pager_obj->state.mutex.acquire(); /* Mark thread to be runable again */ _pager_obj->state.paused = false; - _pager_obj->state.lock.unlock(); + _pager_obj->state.mutex.release(); /* Send a message to the exception handler, to unblock the client */ Msgbuf<16> snd, rcv;