Use Mutex/Blockade instead of Lock

due to changes in Genode repository

Issue genodelabs/genode#3802
This commit is contained in:
Alexander Boettcher
2020-07-16 14:31:24 +02:00
committed by Norman Feske
parent 50334e62f4
commit f19ecb0650
11 changed files with 45 additions and 35 deletions

View File

@@ -1 +1 @@
319da8b104f7eca04998b1f3ae3041e4bca0fd9c
a912520e3a877afd0ecc7cd71b9ca13aee08d713

View File

@@ -10,12 +10,12 @@
#include "private/implementations.h"
#include "private/mutex.h"
#include <base/lock.h>
#include <base/mutex.h>
#include <base/log.h>
static int initialized;
static Genode::Lock *_sodium_lock;
static Genode::Mutex *_sodium_mutex;
extern "C"
int sodium_init(void)
@@ -35,14 +35,14 @@ int sodium_init(void)
int
sodium_crit_enter(void)
{
_sodium_lock->lock();
_sodium_mutex->acquire();
return 0;
}
int
sodium_crit_leave(void)
{
_sodium_lock->unlock();
_sodium_mutex->release();
return 0;
}

View File

@@ -13,16 +13,26 @@ index a311889..967be6a 100644
#define GOOGLE_PROTOBUF_STUBS_MUTEX_H_
-#include <mutex>
+#include <base/lock.h>
+#include <base/mutex.h>
#ifdef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP
@@ -104,7 +104,7 @@ class PROTOBUF_EXPORT GOOGLE_PROTOBUF_CAPABILITY("mutex") WrappedMutex {
@@ -96,15 +96,15 @@
class PROTOBUF_EXPORT GOOGLE_PROTOBUF_CAPABILITY("mutex") WrappedMutex {
public:
WrappedMutex() = default;
- void Lock() GOOGLE_PROTOBUF_ACQUIRE() { mu_.lock(); }
- void Unlock() GOOGLE_PROTOBUF_RELEASE() { mu_.unlock(); }
+ void Lock() GOOGLE_PROTOBUF_ACQUIRE() { mu_.acquire(); }
+ void Unlock() GOOGLE_PROTOBUF_RELEASE() { mu_.release(); }
// Crash if this Mutex is not held exclusively by this thread.
// May fail to crash when it should; will never crash when it should not.
void AssertHeld() const {}
private:
#ifndef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP
- std::mutex mu_;
+ Genode::Lock mu_;
+ Genode::Mutex mu_;
#else // ifndef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP
CriticalSectionLock mu_;
#endif // #ifndef GOOGLE_PROTOBUF_SUPPORT_WINDOWS_XP

View File

@@ -26,8 +26,8 @@
#include <SDL_genode_internal.h>
extern Genode::Env *global_env();
extern Genode::Lock event_lock;
extern Genode::Env *global_env();
extern Genode::Mutex event_mutex;
enum {
@@ -75,7 +75,7 @@ struct Volume_config
if (!_config_rom.valid()) { return; }
Genode::Lock_guard<Genode::Lock> guard(event_lock);
Genode::Mutex::Guard guard(event_mutex);
Genode::Xml_node config = _config_rom.xml();
@@ -212,7 +212,7 @@ static void GENODEAUD_WaitAudio(_THIS)
static void GENODEAUD_PlayAudio(_THIS)
{
Genode::Lock_guard<Genode::Lock> guard(event_lock);
Genode::Mutex::Guard guard(event_mutex);
Audio_out::Connection *c[AUDIO_CHANNELS];
Audio_out::Packet *p[AUDIO_CHANNELS];

View File

@@ -40,7 +40,7 @@
#include <SDL_genode_internal.h>
Genode::Lock event_lock;
Genode::Mutex event_mutex;
Video video_events;
@@ -101,7 +101,7 @@ extern "C" {
void Genode_Fb_PumpEvents(SDL_VideoDevice *t)
{
Genode::Lock_guard<Genode::Lock> guard(event_lock);
Genode::Mutex::Guard guard(event_mutex);
if (video_events.resize_pending) {
video_events.resize_pending = false;

View File

@@ -41,8 +41,8 @@
extern Genode::Env &global_env();
extern Gui::Connection &global_gui();
extern Genode::Lock event_lock;
extern Video video_events;
extern Genode::Mutex event_mutex;
extern Video video_events;
extern "C" {
@@ -68,7 +68,7 @@ extern "C" {
void _handle_mode_change()
{
Genode::Lock_guard<Genode::Lock> guard(event_lock);
Genode::Mutex::Guard guard(event_mutex);
Framebuffer::Mode mode = _gui.mode();
df_mode.w = mode.area.w();

View File

@@ -40,7 +40,7 @@
#include <SDL_genode_internal.h>
Genode::Lock event_lock;
Genode::Mutex event_mutex;
Video video_events;
@@ -107,7 +107,7 @@ extern "C" {
// SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
}
Genode::Lock_guard<Genode::Lock> guard(event_lock);
Genode::Mutex::Guard guard(event_mutex);
if (video_events.resize_pending) {
video_events.resize_pending = false;

View File

@@ -42,8 +42,8 @@
extern Genode::Env &global_env();
extern Gui::Connection &global_gui();
extern Genode::Lock event_lock;
extern Video video_events;
extern Genode::Mutex event_mutex;
extern Video video_events;
extern "C" {
@@ -69,7 +69,7 @@ extern "C" {
void _handle_mode_change()
{
Genode::Lock_guard<Genode::Lock> guard(event_lock);
Genode::Mutex::Guard guard(event_mutex);
Framebuffer::Mode mode = _gui.mode();

View File

@@ -54,7 +54,7 @@ class Flif_capture::Encoder
// TODO: reuse FLIF_IMAGE, do not reallocate
FLIF_IMAGE *_image = nullptr;
Semaphore _semaphore { };
Lock _lock { Lock::LOCKED };
Mutex _mutex { };
public:
@@ -71,11 +71,13 @@ class Flif_capture::Encoder
*/
void entry()
{
_mutex.acquire();
for (;;) {
while (_image == nullptr) {
_lock.unlock();
_mutex.release();
_semaphore.down();
_lock.lock();
_mutex.acquire();
}
char filename[32] { '\0' };
@@ -119,7 +121,7 @@ class Flif_capture::Encoder
if (_image != nullptr)
return;
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
/* TODO: attach/detach each capture? */
Genode::Attached_dataspace fb_ds(_env.rm(), fb_cap);

View File

@@ -18,7 +18,6 @@
/* Genode includes */
#include <file_system/node.h>
#include <base/lock.h>
#include <base/signal.h>
#include <os/path.h>

View File

@@ -58,7 +58,7 @@ extern "C" void data_cb(void *arg, struct udp_pcb *pcb, struct pbuf *p,
class Tftp_rom::Session_component :
public Genode::Rpc_object<Genode::Rom_session>,
public Session_list::Element,
Genode::Lock
Genode::Blockade
{
private:
@@ -90,7 +90,7 @@ class Tftp_rom::Session_component :
inline void finalize()
{
unlock();
wakeup();
_ack_timeout = 0;
if (_chain_head != NULL) {
pbuf_free(_chain_head);
@@ -132,7 +132,6 @@ class Tftp_rom::Session_component :
unsigned long now,
unsigned timeout)
:
Lock(LOCKED),
_env(env),
_filename(namestr),
_pcb(udp_new()),
@@ -309,7 +308,7 @@ class Tftp_rom::Session_component :
Rom_dataspace_capability dataspace() override
{
if (!done()) lock();
if (!done()) block();
Dataspace_capability ds = _dataspace;
return static_cap_cast<Genode::Rom_dataspace>(ds);
@@ -370,7 +369,7 @@ class Tftp_rom::Root : public Genode::Root_component<Session_component>
*/
Lwip::Nic_netif _netif { _env, *md_alloc(), _config_rom.xml() };
class Timeout_dispatcher : Genode::Thread, Genode::Lock
class Timeout_dispatcher : Genode::Thread, Genode::Mutex
{
private:
@@ -390,7 +389,7 @@ class Tftp_rom::Root : public Genode::Root_component<Session_component>
ctx == &_sig_ctx;
ctx = _sig_rec.wait_for_signal().context())
{
Lock::Guard(*this);
Mutex::Guard guard(*this);
Session_component *session = _sessions.first();
if (!session) {
@@ -439,7 +438,7 @@ class Tftp_rom::Root : public Genode::Root_component<Session_component>
void insert(Session_component *session)
{
Lock::Guard(*this);
Mutex::Guard guard(*this);
if (!_sessions.first())
_timer.sigh(_sig_cap);
@@ -449,7 +448,7 @@ class Tftp_rom::Root : public Genode::Root_component<Session_component>
void remove(Session_component *session)
{
Lock::Guard(*this);
Mutex::Guard guard(*this);
_sessions.remove(session);
/* timer will be stopped at the next signal */