mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
parent
a9827c662e
commit
7acc34b48b
@ -17,7 +17,7 @@
|
||||
#include <irq_session/connection.h>
|
||||
#include <irq_session/client.h>
|
||||
#include <base/signal.h>
|
||||
#include <base/lock.h>
|
||||
#include <base/mutex.h>
|
||||
|
||||
namespace ZX{
|
||||
enum {
|
||||
@ -31,26 +31,24 @@ namespace ZX{
|
||||
private:
|
||||
tsession _irq;
|
||||
Genode::Signal_handler<Irq> _irq_handler;
|
||||
Genode::Lock _lock;
|
||||
Genode::Mutex _mutex { };
|
||||
|
||||
void _unlock()
|
||||
{
|
||||
_lock.unlock();
|
||||
_mutex.release();
|
||||
}
|
||||
|
||||
public:
|
||||
Irq(Genode::Env &env, int irq) :
|
||||
_irq(env, irq),
|
||||
_irq_handler(env.ep(), *this, &Irq::_unlock),
|
||||
_lock()
|
||||
_irq_handler(env.ep(), *this, &Irq::_unlock)
|
||||
{
|
||||
_irq.sigh(_irq_handler);
|
||||
}
|
||||
|
||||
Irq(Genode::Env &env, Genode::Irq_session_capability cap) :
|
||||
_irq(cap),
|
||||
_irq_handler(env.ep(), *this, &Irq::_unlock),
|
||||
_lock()
|
||||
_irq_handler(env.ep(), *this, &Irq::_unlock)
|
||||
{
|
||||
_irq.sigh(_irq_handler);
|
||||
}
|
||||
@ -58,7 +56,7 @@ namespace ZX{
|
||||
void wait()
|
||||
{
|
||||
_irq.ack_irq();
|
||||
_lock.lock();
|
||||
_mutex.acquire();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include <base/heap.h>
|
||||
#include <base/allocator.h>
|
||||
#include <base/lock.h>
|
||||
#include <base/mutex.h>
|
||||
|
||||
#include <threads.h>
|
||||
|
||||
@ -27,19 +27,19 @@ extern "C" {
|
||||
return thrd_error;
|
||||
}
|
||||
Genode::Allocator &alloc = ZX::Resource<Genode::Heap>::get_component();
|
||||
mtx->lock = static_cast<void *>(new (alloc) Genode::Lock());
|
||||
mtx->lock = static_cast<void *>(new (alloc) Genode::Mutex());
|
||||
return thrd_success;
|
||||
}
|
||||
|
||||
int mtx_lock(mtx_t *mtx)
|
||||
{
|
||||
static_cast<Genode::Lock *>(mtx->lock)->lock();
|
||||
static_cast<Genode::Mutex *>(mtx->lock)->acquire();
|
||||
return thrd_success;
|
||||
}
|
||||
|
||||
int mtx_unlock(mtx_t *mtx)
|
||||
{
|
||||
static_cast<Genode::Lock *>(mtx->lock)->unlock();
|
||||
static_cast<Genode::Mutex *>(mtx->lock)->release();
|
||||
return thrd_success;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user