os: use Mutex/Blockade

Issue #3612
This commit is contained in:
Alexander Boettcher 2020-02-20 15:47:08 +01:00 committed by Christian Helmuth
parent 3956530634
commit 22d71d5a8b
21 changed files with 119 additions and 120 deletions

View File

@ -17,7 +17,7 @@
/* Genode includes */
#include <file_system_session/rpc_object.h>
#include <util/list.h>
#include <base/lock.h>
#include <base/mutex.h>
#include <base/signal.h>
namespace File_system {
@ -32,7 +32,7 @@ namespace File_system {
private:
Genode::Lock _lock { };
Genode::Mutex _mutex { };
Sink &_sink;
Node_handle const _handle;
@ -57,7 +57,7 @@ namespace File_system {
*/
void notify(Version curr_version)
{
Genode::Lock::Guard guard(_lock);
Genode::Mutex::Guard guard(_mutex);
if (curr_version.value == _handed_out_version.value)
return;
@ -77,7 +77,7 @@ namespace File_system {
*/
void handed_out_version(Version version)
{
Genode::Lock::Guard guard(_lock);
Genode::Mutex::Guard guard(_mutex);
_handed_out_version = version;
}

View File

@ -43,10 +43,10 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object<Rom_session>,
* The ROM module may be written and consumed by different threads,
* e.g., written by the main thread and consumed by the child's
* entrypoint that manages the local ROM service for handing out a
* dynamic config. Hence, the '_lock' is used to synchronize the
* dynamic config. Hence, the '_mutex' is used to synchronize the
* 'load' and 'dataspace' methods.
*/
Lock _lock { };
Mutex _mutex { };
/*
* We keep two dataspaces around. The foreground ('_fg') dataspace
@ -111,7 +111,7 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object<Rom_session>,
*/
void load(void const *data, size_t data_len)
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
if (!_ram) {
Genode::error("no backing store for loading ROM data");
@ -136,7 +136,7 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object<Rom_session>,
Rom_dataspace_capability dataspace() override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
if (!_fg.size() && !_bg_has_pending_data) {
Genode::error("no data loaded");

View File

@ -74,7 +74,7 @@ class Genode::Dynamic_rom_session : public Rpc_object<Rom_session>
* Synchronize calls of 'trigger_update' (called locally) with the
* 'Rom_session' methods (invoked via RPC).
*/
Lock _lock { };
Mutex _mutex { };
Rpc_entrypoint &_ep;
Ram_allocator &_ram;
@ -200,7 +200,7 @@ class Genode::Dynamic_rom_session : public Rpc_object<Rom_session>
*/
void trigger_update()
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
_current_version++;
_notify_client();
@ -213,7 +213,7 @@ class Genode::Dynamic_rom_session : public Rpc_object<Rom_session>
Rom_dataspace_capability dataspace() override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
if (!_ds.constructed())
_unsynchronized_update();
@ -228,14 +228,14 @@ class Genode::Dynamic_rom_session : public Rpc_object<Rom_session>
bool update() override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
return _unsynchronized_update();
}
void sigh(Signal_context_capability sigh) override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
_sigh = sigh;
_notify_client();

View File

@ -279,9 +279,9 @@ class Genode::Packet_descriptor_transmitter
/* facility to send ready-to-receive signals */
Genode::Signal_transmitter _rx_ready { };
Genode::Lock _tx_queue_lock { };
TX_QUEUE *_tx_queue;
bool _tx_wakeup_needed = false;
Genode::Mutex _tx_queue_mutex { };
TX_QUEUE *_tx_queue;
bool _tx_wakeup_needed = false;
/*
* Noncopyable
@ -325,13 +325,13 @@ class Genode::Packet_descriptor_transmitter
bool ready_for_tx()
{
Genode::Lock::Guard lock_guard(_tx_queue_lock);
Genode::Mutex::Guard mutex_guard(_tx_queue_mutex);
return !_tx_queue->full();
}
void tx(typename TX_QUEUE::Packet_descriptor packet)
{
Genode::Lock::Guard lock_guard(_tx_queue_lock);
Genode::Mutex::Guard mutex_guard(_tx_queue_mutex);
do {
/* block for signal if tx queue is full */
@ -352,7 +352,7 @@ class Genode::Packet_descriptor_transmitter
bool try_tx(typename TX_QUEUE::Packet_descriptor packet)
{
Genode::Lock::Guard lock_guard(_tx_queue_lock);
Genode::Mutex::Guard mutex_guard(_tx_queue_mutex);
if (_tx_queue->full())
return false;
@ -367,7 +367,7 @@ class Genode::Packet_descriptor_transmitter
bool tx_wakeup()
{
Genode::Lock::Guard lock_guard(_tx_queue_lock);
Genode::Mutex::Guard mutex_guard(_tx_queue_mutex);
bool signal_submitted = false;
@ -405,9 +405,9 @@ class Genode::Packet_descriptor_receiver
/* facility to send ready-to-transmit signals */
Genode::Signal_transmitter _tx_ready { };
Genode::Lock mutable _rx_queue_lock { };
RX_QUEUE *_rx_queue;
bool _rx_wakeup_needed = false;
Genode::Mutex mutable _rx_queue_mutex { };
RX_QUEUE *_rx_queue;
bool _rx_wakeup_needed = false;
/*
* Noncopyable
@ -451,13 +451,13 @@ class Genode::Packet_descriptor_receiver
bool ready_for_rx()
{
Genode::Lock::Guard lock_guard(_rx_queue_lock);
Genode::Mutex::Guard mutex_guard(_rx_queue_mutex);
return !_rx_queue->empty();
}
void rx(typename RX_QUEUE::Packet_descriptor *out_packet)
{
Genode::Lock::Guard lock_guard(_rx_queue_lock);
Genode::Mutex::Guard mutex_guard(_rx_queue_mutex);
while (_rx_queue->empty())
_rx_ready.wait_for_signal();
@ -470,7 +470,7 @@ class Genode::Packet_descriptor_receiver
typename RX_QUEUE::Packet_descriptor try_rx()
{
Genode::Lock::Guard lock_guard(_rx_queue_lock);
Genode::Mutex::Guard mutex_guard(_rx_queue_mutex);
typename RX_QUEUE::Packet_descriptor packet { };
@ -485,7 +485,7 @@ class Genode::Packet_descriptor_receiver
bool rx_wakeup()
{
Genode::Lock::Guard lock_guard(_rx_queue_lock);
Genode::Mutex::Guard mutex_guard(_rx_queue_mutex);
bool signal_submitted = false;
@ -501,7 +501,7 @@ class Genode::Packet_descriptor_receiver
typename RX_QUEUE::Packet_descriptor rx_peek() const
{
Genode::Lock::Guard lock_guard(_rx_queue_lock);
Genode::Mutex::Guard mutex_guard(_rx_queue_mutex);
return _rx_queue->peek();
}
};

View File

@ -36,15 +36,15 @@ struct Genode::Ring_buffer_unsynchronized
void up() { }
};
struct Lock
struct Mutex
{
void lock() { }
void unlock() { }
void acquire() { }
void release() { }
};
struct Lock_guard
struct Mutex_guard
{
Lock_guard(Lock &) { }
Mutex_guard(Mutex &) { }
};
};
@ -52,8 +52,8 @@ struct Genode::Ring_buffer_unsynchronized
struct Genode::Ring_buffer_synchronized
{
typedef Genode::Semaphore Sem;
typedef Genode::Lock Lock;
typedef Genode::Lock::Guard Lock_guard;
typedef Genode::Mutex Mutex;
typedef Genode::Mutex::Guard Mutex_guard;
};
@ -77,8 +77,8 @@ class Genode::Ring_buffer
int _head = 0;
int _tail = 0;
typename SYNC_POLICY::Sem _sem { }; /* element counter */
typename SYNC_POLICY::Lock _head_lock { }; /* synchronize add */
typename SYNC_POLICY::Sem _sem { }; /* element counter */
typename SYNC_POLICY::Mutex _head_lock { }; /* synchronize add */
ET _queue[QUEUE_SIZE] { };
@ -98,7 +98,7 @@ class Genode::Ring_buffer
*/
void add(ET ev)
{
typename SYNC_POLICY::Lock_guard lock_guard(_head_lock);
typename SYNC_POLICY::Mutex_guard mutex_guard(_head_lock);
if ((_head + 1)%QUEUE_SIZE != _tail) {
_queue[_head] = ev;

View File

@ -189,9 +189,9 @@ class Genode::Slave::Connection_base
struct Service : Genode::Service, Session_state::Ready_callback,
Session_state::Closed_callback
{
Policy &_policy;
Lock _lock { Lock::LOCKED };
bool _alive = false;
Policy &_policy;
Blockade _blockade { };
bool _alive = false;
Service(Policy &policy)
:
@ -240,13 +240,13 @@ class Genode::Slave::Connection_base
void session_ready(Session_state &session) override
{
_alive = session.alive();
_lock.unlock();
_blockade.wakeup();
}
/**
* Session_state::Closed_callback
*/
void session_closed(Session_state &s) override { _lock.unlock(); }
void session_closed(Session_state &s) override { _blockade.wakeup(); }
/**
* Service ('Ram_transfer::Account') interface
@ -290,7 +290,7 @@ class Genode::Slave::Connection_base
_connection(_service, _id_space, { 1 }, args, affinity)
{
_policy.trigger_session_requests();
_service._lock.lock();
_service._blockade.block();
if (!_service._alive)
throw Service_denied();
}
@ -298,7 +298,7 @@ class Genode::Slave::Connection_base
~Connection_base()
{
_policy.trigger_session_requests();
_service._lock.lock();
_service._blockade.block();
}
typedef typename CONNECTION::Session_type SESSION;

View File

@ -17,7 +17,7 @@
/* Genode includes */
#include <util/misc_math.h>
#include <util/string.h>
#include <base/lock.h>
#include <base/mutex.h>
#include <base/rpc_client.h>
#include <base/attached_dataspace.h>
@ -30,7 +30,7 @@ class Terminal::Session_client : public Genode::Rpc_client<Session>
{
private:
Genode::Lock _lock { };
Genode::Mutex _mutex { };
/**
* Shared-memory buffer used for carrying the payload
@ -52,7 +52,7 @@ class Terminal::Session_client : public Genode::Rpc_client<Session>
Genode::size_t read(void *buf, Genode::size_t buf_size) override
{
Genode::Lock::Guard _guard(_lock);
Genode::Mutex::Guard _guard(_mutex);
/* instruct server to fill the I/O buffer */
Genode::size_t num_bytes = call<Rpc_read>(buf_size);
@ -66,7 +66,7 @@ class Terminal::Session_client : public Genode::Rpc_client<Session>
Genode::size_t write(void const *buf, Genode::size_t num_bytes) override
{
Genode::Lock::Guard _guard(_lock);
Genode::Mutex::Guard _guard(_mutex);
Genode::size_t written_bytes = 0;
char const * const src = (char const *)buf;

View File

@ -18,7 +18,7 @@
#include <util/misc_math.h>
#include <util/xml_node.h>
#include <util/string.h>
#include <base/lock.h>
#include <base/mutex.h>
#include <base/env.h>
#include <base/signal.h>
#include <base/allocator.h>
@ -41,7 +41,7 @@ namespace Vfs {
using Genode::memcpy;
using Genode::memset;
typedef unsigned long long file_size;
using Genode::Lock;
using Genode::Mutex;
using Genode::List;
using Genode::Xml_node;
using Genode::Signal_context_capability;

View File

@ -66,7 +66,7 @@ class Pl050
_Channel(_Channel const &);
_Channel &operator = (_Channel const &);
Genode::Lock _lock { };
Genode::Mutex _mutex { };
Genode::Attached_io_mem_dataspace _io_mem;
volatile Genode::uint32_t *_reg_base;
@ -96,7 +96,7 @@ class Pl050
*/
unsigned char read() override
{
Genode::Lock::Guard guard(_lock);
Genode::Mutex::Guard guard(_mutex);
while (empty())
if (_input_pending())

View File

@ -114,7 +114,7 @@ class I8042
*/
void flush_read()
{
Genode::Lock::Guard guard(_i8042._lock);
Genode::Mutex::Guard guard(_i8042._mutex);
while (_i8042._output_buffer_full())
_i8042._read_and_route();
@ -143,7 +143,7 @@ class I8042
void write(unsigned char value) override
{
Genode::Lock::Guard guard(_i8042._lock);
Genode::Mutex::Guard guard(_i8042._mutex);
if (_aux)
_i8042._command(CMD_AUX_WRITE);
@ -255,9 +255,9 @@ class I8042
* Both serial interfaces may be used by different
* threads, e.g., interrupt handlers. Hence, controller
* transactions (read/write sequences) must be protected
* with a lock.
* with a mutex.
*/
Genode::Lock _lock { };
Genode::Mutex _mutex { };
public:

View File

@ -141,9 +141,9 @@ class Platform::Irq_component : public Platform::Irq_proxy
Genode::Allocator *heap = nullptr)
{
static Genode::List<Irq_proxy> proxies;
static Genode::Lock proxies_lock;
static Genode::Mutex proxies_mutex;
Genode::Lock::Guard lock_guard(proxies_lock);
Genode::Mutex::Guard mutex_guard(proxies_mutex);
/* lookup proxy in database */
for (Irq_proxy *p = proxies.first(); p; p = p->next())

View File

@ -6,7 +6,7 @@
*/
/*
* Copyright (C) 2009-2017 Genode Labs GmbH
* Copyright (C) 2009-2020 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
@ -15,6 +15,8 @@
#ifndef _DRIVERS__PLATFORM__SPEC__X86__IRQ_PROXY_H_
#define _DRIVERS__PLATFORM__SPEC__X86__IRQ_PROXY_H_
#include <base/mutex.h>
namespace Platform {
class Irq_sigh;
class Irq_proxy;
@ -52,9 +54,9 @@ class Platform::Irq_proxy : private Genode::List<Platform::Irq_proxy>::Element
protected:
unsigned _irq_number;
Genode::Lock _mutex; /* protects this object */
int _num_sharers; /* number of clients sharing this IRQ */
unsigned _irq_number;
Genode::Mutex _mutex { }; /* protects this object */
int _num_sharers; /* number of clients sharing this IRQ */
Genode::List<Irq_sigh> _sigh_list { };
@ -68,8 +70,7 @@ class Platform::Irq_proxy : private Genode::List<Platform::Irq_proxy>::Element
Irq_proxy(unsigned irq_number)
:
_irq_number(irq_number),
_mutex(Genode::Lock::UNLOCKED), _num_sharers(0),
_irq_number(irq_number), _num_sharers(0),
_num_acknowledgers(0), _woken_up(false)
{ }
@ -80,7 +81,7 @@ class Platform::Irq_proxy : private Genode::List<Platform::Irq_proxy>::Element
*/
virtual bool ack_irq()
{
Genode::Lock::Guard lock_guard(_mutex);
Genode::Mutex::Guard mutex_guard(_mutex);
_num_acknowledgers++;
@ -100,7 +101,7 @@ class Platform::Irq_proxy : private Genode::List<Platform::Irq_proxy>::Element
*/
void notify_about_irq()
{
Genode::Lock::Guard lock_guard(_mutex);
Genode::Mutex::Guard mutex_guard(_mutex);
/* reset acknowledger state */
_num_acknowledgers = 0;
@ -115,7 +116,7 @@ class Platform::Irq_proxy : private Genode::List<Platform::Irq_proxy>::Element
virtual bool add_sharer(Irq_sigh *s)
{
Genode::Lock::Guard lock_guard(_mutex);
Genode::Mutex::Guard mutex_guard(_mutex);
++_num_sharers;
_sigh_list.insert(s);
@ -125,7 +126,7 @@ class Platform::Irq_proxy : private Genode::List<Platform::Irq_proxy>::Element
virtual bool remove_sharer(Irq_sigh *s)
{
Genode::Lock::Guard lock_guard(_mutex);
Genode::Mutex::Guard mutex_guard(_mutex);
_sigh_list.remove(s);
--_num_sharers;

View File

@ -34,7 +34,7 @@ class Vfs::Block_file_system : public Single_file_system
/*
* Serialize access to packet stream of the block session
*/
Lock _lock { };
Mutex _mutex { };
char *_block_buffer;
unsigned _block_buffer_count;
@ -66,7 +66,7 @@ class Vfs::Block_file_system : public Single_file_system
Genode::Allocator &_alloc;
Label &_label;
Lock &_lock;
Mutex &_mutex;
char *_block_buffer;
unsigned &_block_buffer_count;
Genode::Allocator_avl &_tx_block_alloc;
@ -104,7 +104,7 @@ class Vfs::Block_file_system : public Single_file_system
while (true) {
try {
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
packet = _block.alloc_packet(packet_size);
break;
@ -119,7 +119,7 @@ class Vfs::Block_file_system : public Single_file_system
}
}
}
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
Block::Packet_descriptor p(packet, op, nr, packet_count);
@ -148,7 +148,7 @@ class Vfs::Block_file_system : public Single_file_system
File_io_service &fs,
Genode::Allocator &alloc,
Label &label,
Lock &lock,
Mutex &mutex,
char *block_buffer,
unsigned &block_buffer_count,
Genode::Allocator_avl &tx_block_alloc,
@ -163,7 +163,7 @@ class Vfs::Block_file_system : public Single_file_system
: Single_vfs_handle(ds, fs, alloc, 0),
_alloc(alloc),
_label(label),
_lock(lock),
_mutex(mutex),
_block_buffer(block_buffer),
_block_buffer_count(block_buffer_count),
_tx_block_alloc(tx_block_alloc),
@ -393,7 +393,7 @@ class Vfs::Block_file_system : public Single_file_system
try {
*out_handle = new (alloc) Block_vfs_handle(*this, *this, alloc,
_label, _lock,
_label, _mutex,
_block_buffer,
_block_buffer_count,
_tx_block_alloc,

View File

@ -29,13 +29,13 @@ class Vfs::Fs_file_system : public File_system
private:
/*
* Lock used to serialize the interaction with the packet stream of the
* Mutex used to serialize the interaction with the packet stream of the
* file-system session.
*
* XXX Once, we change the VFS file-system interface to use
* asynchronous read/write operations, we can possibly remove it.
*/
Lock _lock { };
Mutex _mutex { };
Vfs::Env &_env;
Genode::Allocator_avl _fs_packet_alloc { &_env.alloc() };
@ -601,12 +601,12 @@ class Vfs::Fs_file_system : public File_system
Genode::warning("ack for unknown File_system handle ", id); }
if (packet.operation() == Packet_descriptor::WRITE) {
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
source.release_packet(packet);
}
if (packet.operation() == Packet_descriptor::WRITE_TIMESTAMP) {
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
source.release_packet(packet);
}
}
@ -801,7 +801,7 @@ class Vfs::Fs_file_system : public File_system
Open_result open(char const *path, unsigned vfs_mode, Vfs_handle **out_handle,
Genode::Allocator& alloc) override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
Absolute_path dir_path(path);
dir_path.strip_last_element();
@ -848,7 +848,7 @@ class Vfs::Fs_file_system : public File_system
Opendir_result opendir(char const *path, bool create,
Vfs_handle **out_handle, Allocator &alloc) override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
Absolute_path dir_path(path);
@ -873,7 +873,7 @@ class Vfs::Fs_file_system : public File_system
Openlink_result openlink(char const *path, bool create,
Vfs_handle **out_handle, Allocator &alloc) override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
/*
* Canonicalize path (i.e., path must start with '/')
@ -914,7 +914,7 @@ class Vfs::Fs_file_system : public File_system
void close(Vfs_handle *vfs_handle) override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
Fs_vfs_handle *fs_handle = static_cast<Fs_vfs_handle *>(vfs_handle);
if (fs_handle->enqueued())
@ -976,7 +976,7 @@ class Vfs::Fs_file_system : public File_system
Write_result write(Vfs_handle *vfs_handle, char const *buf,
file_size buf_size, file_size &out_count) override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
Fs_vfs_handle &handle = static_cast<Fs_vfs_handle &>(*vfs_handle);
@ -986,7 +986,7 @@ class Vfs::Fs_file_system : public File_system
bool queue_read(Vfs_handle *vfs_handle, file_size count) override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
Fs_vfs_handle *handle = static_cast<Fs_vfs_handle *>(vfs_handle);
@ -999,7 +999,7 @@ class Vfs::Fs_file_system : public File_system
Read_result complete_read(Vfs_handle *vfs_handle, char *dst, file_size count,
file_size &out_count) override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
out_count = 0;
@ -1064,7 +1064,7 @@ class Vfs::Fs_file_system : public File_system
bool queue_sync(Vfs_handle *vfs_handle) override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
Fs_vfs_handle *handle = static_cast<Fs_vfs_handle *>(vfs_handle);
@ -1073,7 +1073,7 @@ class Vfs::Fs_file_system : public File_system
Sync_result complete_sync(Vfs_handle *vfs_handle) override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
Fs_vfs_handle *handle = static_cast<Fs_vfs_handle *>(vfs_handle);
@ -1082,7 +1082,7 @@ class Vfs::Fs_file_system : public File_system
bool update_modification_timestamp(Vfs_handle *vfs_handle, Vfs::Timestamp time) override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
Fs_vfs_handle *handle = static_cast<Fs_vfs_handle *>(vfs_handle);

View File

@ -93,7 +93,7 @@ struct Vfs_ram::Watch_handle final : public Vfs_watch_handle,
};
class Vfs_ram::Node : private Genode::Avl_node<Node>, private Genode::Lock
class Vfs_ram::Node : private Genode::Avl_node<Node>, private Genode::Mutex
{
private:
@ -123,8 +123,8 @@ class Vfs_ram::Node : private Genode::Avl_node<Node>, private Genode::Lock
public:
using Lock::lock;
using Lock::unlock;
using Mutex::acquire;
using Mutex::release;
unsigned inode;
@ -245,9 +245,9 @@ class Vfs_ram::Node : private Genode::Avl_node<Node>, private Genode::Lock
{
Node &node;
Guard(Node *guard_node) : node(*guard_node) { node.lock(); }
Guard(Node *guard_node) : node(*guard_node) { node.acquire(); }
~Guard() { node.unlock(); }
~Guard() { node.release(); }
};
};
@ -737,9 +737,9 @@ class Vfs::Ram_file_system : public Vfs::File_system
try { link = new (_env.alloc()) Symlink(name); }
catch (Out_of_memory) { return OPENLINK_ERR_NO_SPACE; }
link->lock();
link->acquire();
parent->adopt(link);
link->unlock();
link->release();
parent->notify();
} else {
@ -838,7 +838,7 @@ class Vfs::Ram_file_system : public Vfs::File_system
/* unlock the node so a second guard can be constructed */
if (from_dir == to_dir)
from_dir->unlock();
from_dir->Node::release();
Node::Guard to_guard(to_dir);
@ -848,7 +848,7 @@ class Vfs::Ram_file_system : public Vfs::File_system
Node *to_node = to_dir->child(new_name);
if (to_node) {
to_node->lock();
to_node->acquire();
if (Directory *dir = dynamic_cast<Directory*>(to_node))
if (dir->length() || (!dynamic_cast<Directory*>(from_node)))
@ -885,7 +885,7 @@ class Vfs::Ram_file_system : public Vfs::File_system
Node *node = parent->child(basename(path));
if (!node) return UNLINK_ERR_NO_ENTRY;
node->lock();
node->acquire();
parent->release(node);
node->notify();
parent->notify();

View File

@ -492,7 +492,7 @@ class Vfs::Tar_file_system : public File_system
struct Num_dirent_cache
{
Lock lock { };
Mutex mutex { };
Node &root_node;
bool valid; /* true after first lookup */
char key[256]; /* key used for lookup */
@ -503,7 +503,7 @@ class Vfs::Tar_file_system : public File_system
file_size num_dirent(char const *path)
{
Lock::Guard guard(lock);
Mutex::Guard guard(mutex);
/* check for cache miss */
if (!valid || strcmp(path, key) != 0) {

View File

@ -43,7 +43,7 @@ class Loader::Session_component : public Rpc_object<Session>
Entrypoint &_ep;
Allocator &_md_alloc;
Rom_module_registry &_rom_modules;
Lock _lock { };
Mutex _mutex { };
List<Rom_session_component> _rom_sessions { };
void _close(Rom_session_component &rom)
@ -61,7 +61,7 @@ class Loader::Session_component : public Rpc_object<Session>
~Local_rom_factory()
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
while (_rom_sessions.first())
_close(*_rom_sessions.first());
@ -71,7 +71,7 @@ class Loader::Session_component : public Rpc_object<Session>
{
/* try to find ROM module at local ROM service */
try {
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
Session_label const label = label_from_args(args.string());
Session_label const name = label.last_element();
@ -94,7 +94,7 @@ class Loader::Session_component : public Rpc_object<Session>
void destroy(Rom_session_component &session) override
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
_close(session);
}

View File

@ -41,7 +41,7 @@ namespace Genode {
Signal_context_capability _sigh { };
Lock _lock { Lock::LOCKED };
Blockade _blockade { };
public:
@ -66,8 +66,8 @@ namespace Genode {
bool has_name(Name const &name) const { return _name == name; }
void lock() { _lock.lock(); }
void unlock() { _lock.unlock(); }
void lock() { _blockade.block(); }
void unlock() { _blockade.wakeup(); }
/**
* Return dataspace as handed out to loader session
@ -155,7 +155,7 @@ namespace Genode {
Env &_env;
Xml_node const _config;
Lock _lock { };
Mutex _mutex { };
Ram_allocator &_ram_allocator;
Allocator &_md_alloc;
List<Rom_module> _list { };
@ -184,7 +184,7 @@ namespace Genode {
~Rom_module_registry()
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
while (_list.first()) {
Rom_module *rom = _list.first();
@ -201,7 +201,7 @@ namespace Genode {
*/
Rom_module &lookup_and_lock(Rom_module::Name const &name)
{
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
Rom_module *curr = _list.first();
for (; curr; curr = curr->next()) {
@ -222,7 +222,7 @@ namespace Genode {
}
catch (Lookup_failed) {
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
Rom_module *module = new (&_md_alloc)
Rom_module(_env, _config, name, _ram_allocator,
@ -243,7 +243,7 @@ namespace Genode {
}
catch (Lookup_failed) {
Lock::Guard guard(_lock);
Mutex::Guard guard(_mutex);
Rom_module *module = new (&_md_alloc)
Rom_module(_env, _config, name, _ram_allocator,

View File

@ -140,8 +140,8 @@ unique_child_name(Children const &children, Bomb_child::Name const &binary_name,
unsigned const generation)
{
/* serialize calls to this function */
static Lock lock;
Lock::Guard guard(lock);
static Mutex mutex;
Mutex::Guard guard(mutex);
for (unsigned cnt = 1; ; cnt++) {

View File

@ -193,8 +193,6 @@ class Test::Parent
Timer::Connection _timer { _env };
Lock _yield_blockade { };
void _print_status()
{
log("quota: ", _child.pd().ram_quota().value / 1024, " KiB "

View File

@ -101,7 +101,7 @@ struct Lock_test : Test
bool stop { false };
Microseconds us { 1000 };
Lock lock { };
Mutex mutex { };
Timer::One_shot_timeout<Lock_test> ot1 { timer, *this, &Lock_test::handle_ot1 };
Timer::One_shot_timeout<Lock_test> ot2 { timer, *this, &Lock_test::handle_ot2 };
Timer::One_shot_timeout<Lock_test> ot3 { timer, *this, &Lock_test::handle_ot3 };
@ -129,7 +129,7 @@ struct Lock_test : Test
stop = true;
return;
}
Lock_guard<Lock> lock_guard(lock);
Mutex::Guard mutex_guard(mutex);
us.value--;
ot.schedule(us);
}