dde_linux: use Mutex/Blockade

Issue #3805
This commit is contained in:
Alexander Boettcher 2020-07-06 14:04:57 +02:00 committed by Norman Feske
parent b7cdb5840a
commit 5516dbcb1f
8 changed files with 24 additions and 24 deletions

View File

@ -14,7 +14,6 @@
/* Genode includes */ /* Genode includes */
#include <base/allocator.h> #include <base/allocator.h>
#include <base/entrypoint.h> #include <base/entrypoint.h>
#include <base/lock.h>
#include <base/signal.h> #include <base/signal.h>
#include <util/misc_math.h> #include <util/misc_math.h>

View File

@ -14,7 +14,6 @@
/* Genode includes */ /* Genode includes */
#include <base/allocator.h> #include <base/allocator.h>
#include <base/entrypoint.h> #include <base/entrypoint.h>
#include <base/lock.h>
#include <base/signal.h> #include <base/signal.h>
#include <irq_session/client.h> #include <irq_session/client.h>
#include <util/misc_math.h> #include <util/misc_math.h>

View File

@ -330,10 +330,10 @@ struct Wifi::Frontend
Msg_buffer _msg; Msg_buffer _msg;
Genode::Lock _notify_lock { Genode::Lock::UNLOCKED }; Genode::Blockade _notify_blockade { };
void _notify_lock_lock() { _notify_lock.lock(); } void _notify_lock_lock() { _notify_blockade.block(); }
void _notify_lock_unlock() { _notify_lock.unlock(); } void _notify_lock_unlock() { _notify_blockade.wakeup(); }
bool _rfkilled { false }; bool _rfkilled { false };
@ -1568,6 +1568,9 @@ struct Wifi::Frontend
_config_rom.sigh(_config_sigh); _config_rom.sigh(_config_sigh);
_scan_timer.sigh(_scan_timer_sigh); _scan_timer.sigh(_scan_timer_sigh);
/* set/initialize as unblocked */
_notify_blockade.wakeup();
try { try {
_ap_reporter.construct(env, "accesspoints", "accesspoints"); _ap_reporter.construct(env, "accesspoints", "accesspoints");
_ap_reporter->generate([&] (Genode::Xml_generator &xml) { }); _ap_reporter->generate([&] (Genode::Xml_generator &xml) { });

View File

@ -93,7 +93,8 @@ void *wifi_get_buffer(void)
/* exported by wifi.lib.so */ /* exported by wifi.lib.so */
extern void wifi_init(Genode::Env&, Genode::Lock&, bool, Genode::Signal_context_capability); extern void wifi_init(Genode::Env&, Genode::Blockade&, bool,
Genode::Signal_context_capability);
struct Main struct Main
@ -103,21 +104,21 @@ struct Main
Genode::Constructible<Wpa_thread> _wpa; Genode::Constructible<Wpa_thread> _wpa;
Genode::Constructible<Wifi::Frontend> _frontend; Genode::Constructible<Wifi::Frontend> _frontend;
Genode::Lock _wpa_startup_lock { Genode::Lock::LOCKED }; Genode::Blockade _wpa_startup_blockade { };
Main(Genode::Env &env) : env(env) Main(Genode::Env &env) : env(env)
{ {
_frontend.construct(env); _frontend.construct(env);
_wifi_frontend = &*_frontend; _wifi_frontend = &*_frontend;
_wpa.construct(env, _wpa_startup_lock); _wpa.construct(env, _wpa_startup_blockade);
/* /*
* Forcefully disable 11n but for convenience the attribute is used the * Forcefully disable 11n but for convenience the attribute is used the
* other way araound. * other way araound.
*/ */
bool const disable_11n = !_frontend->use_11n(); bool const disable_11n = !_frontend->use_11n();
wifi_init(env, _wpa_startup_lock, disable_11n, wifi_init(env, _wpa_startup_blockade, disable_11n,
_frontend->rfkill_sigh()); _frontend->rfkill_sigh());
} }
}; };

View File

@ -13,8 +13,8 @@
*/ */
/* Genode includes */ /* Genode includes */
#include <base/blockade.h>
#include <base/env.h> #include <base/env.h>
#include <base/lock.h>
#include <base/sleep.h> #include <base/sleep.h>
/* libc includes */ /* libc includes */
@ -40,14 +40,14 @@ void * Wpa_thread::_entry_trampoline(void *arg)
void Wpa_thread::_entry() void Wpa_thread::_entry()
{ {
/* wait until the wifi driver is up and running */ /* wait until the wifi driver is up and running */
_lock.lock(); _blockade.block();
_exit = wpa_main(); _exit = wpa_main();
Genode::sleep_forever(); Genode::sleep_forever();
} }
Wpa_thread::Wpa_thread(Genode::Env &env, Genode::Lock &lock) Wpa_thread::Wpa_thread(Genode::Env &env, Genode::Blockade &blockade)
: _lock(lock), _exit(-1) : _blockade(blockade), _exit(-1)
{ {
pthread_t tid = 0; pthread_t tid = 0;
if (pthread_create(&tid, 0, _entry_trampoline, this) != 0) { if (pthread_create(&tid, 0, _entry_trampoline, this) != 0) {

View File

@ -17,14 +17,14 @@
namespace Genode { namespace Genode {
struct Env; struct Env;
struct Lock; struct Blockade;
} }
class Wpa_thread class Wpa_thread
{ {
private: private:
Genode::Lock &_lock; Genode::Blockade &_blockade;
int _exit; int _exit;
static void * _entry_trampoline(void *arg); static void * _entry_trampoline(void *arg);
@ -33,7 +33,7 @@ class Wpa_thread
public: public:
Wpa_thread(Genode::Env &env, Genode::Lock &lock); Wpa_thread(Genode::Env &, Genode::Blockade &);
}; };
#endif /* _WIFI__WPA_H_ */ #endif /* _WIFI__WPA_H_ */

View File

@ -13,7 +13,7 @@
/* Genode includes */ /* Genode includes */
#include <base/env.h> #include <base/env.h>
#include <base/lock.h> #include <base/blockade.h>
/* local includes */ /* local includes */
#include <firmware_list.h> #include <firmware_list.h>
@ -113,7 +113,7 @@ struct net init_net;
LIST_HEAD(net_namespace_list); LIST_HEAD(net_namespace_list);
static Genode::Lock *_wpa_lock; static Genode::Blockade *_wpa_blockade;
static void run_linux(void *args) static void run_linux(void *args)
@ -146,7 +146,7 @@ static void run_linux(void *args)
Genode::sleep_forever(); Genode::sleep_forever();
} }
_wpa_lock->unlock(); _wpa_blockade->wakeup();
_lx_init_done = true; _lx_init_done = true;
@ -180,7 +180,7 @@ static void run_linux(void *args)
unsigned long jiffies; unsigned long jiffies;
void wifi_init(Genode::Env &env, Genode::Lock &lock, bool disable_11n, void wifi_init(Genode::Env &env, Genode::Blockade &blockade, bool disable_11n,
Genode::Signal_context_capability rfkill) Genode::Signal_context_capability rfkill)
{ {
Lx_kit::construct_env(env); Lx_kit::construct_env(env);
@ -194,7 +194,7 @@ void wifi_init(Genode::Env &env, Genode::Lock &lock, bool disable_11n,
LX_MUTEX_INIT(rfkill_global_mutex); LX_MUTEX_INIT(rfkill_global_mutex);
LX_MUTEX_INIT(rtnl_mutex); LX_MUTEX_INIT(rtnl_mutex);
_wpa_lock = &lock; _wpa_blockade = &blockade;
INIT_LIST_HEAD(&init_net.dev_base_head); INIT_LIST_HEAD(&init_net.dev_base_head);
/* add init_net namespace to namespace list */ /* add init_net namespace to namespace list */

View File

@ -15,7 +15,6 @@
/* Genode includes */ /* Genode includes */
#include <base/env.h> #include <base/env.h>
#include <base/lock.h>
#include <base/log.h> #include <base/log.h>
#include <base/sleep.h> #include <base/sleep.h>
#include <base/thread.h> #include <base/thread.h>
@ -39,7 +38,6 @@ class Lx_kit::Scheduler : public Lx::Scheduler
bool verbose = false; bool verbose = false;
Lx_kit::List<Lx::Task> _present_list; Lx_kit::List<Lx::Task> _present_list;
Genode::Lock _present_list_mutex;
Lx::Task *_current = nullptr; /* currently scheduled task */ Lx::Task *_current = nullptr; /* currently scheduled task */