1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:54:58 +00:00

Kernel: Rename Lock to Mutex

Let's be explicit about what kind of lock this is meant to be.
This commit is contained in:
Andreas Kling 2021-07-17 21:09:51 +02:00
parent a803c4026c
commit cee9528168
51 changed files with 140 additions and 140 deletions

View file

@ -9,7 +9,7 @@
#include <AK/RefPtr.h>
#include <Kernel/ACPI/Parser.h>
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/VM/PhysicalPage.h>

View file

@ -130,7 +130,7 @@ set(KERNEL_SOURCES
KLexicalPath.cpp
KString.cpp
KSyms.cpp
Lock.cpp
Mutex.cpp
Net/E1000ENetworkAdapter.cpp
Net/E1000NetworkAdapter.cpp
Net/IPv4Socket.cpp

View file

@ -19,7 +19,7 @@
#include <AK/HashMap.h>
#include <Kernel/Devices/AsyncDeviceRequest.h>
#include <Kernel/FileSystem/File.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/UnixTypes.h>
namespace Kernel {

View file

@ -8,7 +8,7 @@
#include <AK/Types.h>
#include <Kernel/KBuffer.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/Thread.h>
#include <Kernel/UserOrKernelBuffer.h>
@ -66,7 +66,7 @@ private:
size_t m_read_buffer_index { 0 };
size_t m_space_for_writing { 0 };
bool m_empty { true };
mutable Lock m_lock { "DoubleBuffer" };
mutable Mutex m_lock { "DoubleBuffer" };
};
}

View file

@ -42,7 +42,7 @@ private:
DiskCache& cache() const;
void flush_specific_block_if_needed(BlockIndex index);
mutable Lock m_cache_lock;
mutable Mutex m_cache_lock;
mutable OwnPtr<DiskCache> m_cache;
};

View file

@ -9,7 +9,7 @@
#include <AK/StdLibExtras.h>
#include <Kernel/FileSystem/FIFO.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/Process.h>
#include <Kernel/Thread.h>

View file

@ -8,7 +8,7 @@
#include <Kernel/DoubleBuffer.h>
#include <Kernel/FileSystem/File.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/UnixTypes.h>
#include <Kernel/WaitQueue.h>
@ -61,7 +61,7 @@ private:
WaitQueue m_read_open_queue;
WaitQueue m_write_open_queue;
Lock m_open_lock;
Mutex m_open_lock;
};
}

View file

@ -219,7 +219,7 @@ KResultOr<NonnullOwnPtr<KBuffer>> FileDescription::read_entire_file()
KResultOr<size_t> FileDescription::get_dir_entries(UserOrKernelBuffer& output_buffer, size_t size)
{
Locker locker(m_lock, Lock::Mode::Shared);
Locker locker(m_lock, Mutex::Mode::Shared);
if (!is_directory())
return ENOTDIR;

View file

@ -156,7 +156,7 @@ private:
bool m_direct : 1 { false };
FIFO::Direction m_fifo_direction { FIFO::Direction::Neither };
Lock m_lock { "FileDescription" };
Mutex m_lock { "FileDescription" };
};
}

View file

@ -12,7 +12,7 @@
#include <Kernel/FileSystem/InodeIdentifier.h>
#include <Kernel/Forward.h>
#include <Kernel/KResult.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/UnixTypes.h>
#include <Kernel/UserOrKernelBuffer.h>
@ -69,7 +69,7 @@ protected:
void set_block_size(u64 size) { m_block_size = size; }
void set_fragment_size(size_t size) { m_fragment_size = size; }
mutable Lock m_lock { "FS" };
mutable Mutex m_lock { "FS" };
private:
unsigned m_fsid { 0 };

View file

@ -19,7 +19,7 @@
#include <Kernel/FileSystem/InodeMetadata.h>
#include <Kernel/Forward.h>
#include <Kernel/KResult.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
namespace Kernel {
@ -109,7 +109,7 @@ protected:
void did_modify_contents();
void did_delete_self();
mutable Lock m_lock { "Inode" };
mutable Mutex m_lock { "Inode" };
private:
FileSystem& m_file_system;

View file

@ -66,7 +66,7 @@ public:
private:
explicit InodeWatcher() { }
mutable Lock m_lock;
mutable Mutex m_lock;
struct Event {
int wd { 0 };

View file

@ -135,7 +135,7 @@ private:
ProtocolVersion m_remote_protocol_version { ProtocolVersion::v9P2000 };
size_t m_max_message_size { 4 * KiB };
Lock m_send_lock { "Plan9FS send" };
Mutex m_send_lock { "Plan9FS send" };
Plan9FSBlockCondition m_completion_blocker;
HashMap<u16, NonnullRefPtr<ReceiveCompletion>> m_completions;

View file

@ -12,7 +12,7 @@
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/Forward.h>
#include <Kernel/KBufferBuilder.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/ProcessExposed.h>
namespace Kernel {

View file

@ -33,10 +33,10 @@ public:
void register_new_component(SysFSComponent&);
SysFSDirectory& root_folder() { return m_root_folder; }
Lock& get_lock() { return m_lock; }
Mutex& get_lock() { return m_lock; }
private:
Lock m_lock;
Mutex m_lock;
NonnullRefPtr<SysFSRootDirectory> m_root_folder;
};

View file

@ -63,7 +63,7 @@ unsigned TmpFS::next_inode_index()
RefPtr<Inode> TmpFS::get_inode(InodeIdentifier identifier) const
{
Locker locker(m_lock, Lock::Mode::Shared);
Locker locker(m_lock, Mutex::Mode::Shared);
VERIFY(identifier.fsid() == fsid());
auto it = m_inodes.find(identifier.index());
@ -105,14 +105,14 @@ RefPtr<TmpFSInode> TmpFSInode::create_root(TmpFS& fs)
InodeMetadata TmpFSInode::metadata() const
{
Locker locker(m_lock, Lock::Mode::Shared);
Locker locker(m_lock, Mutex::Mode::Shared);
return m_metadata;
}
KResult TmpFSInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
{
Locker locker(m_lock, Lock::Mode::Shared);
Locker locker(m_lock, Mutex::Mode::Shared);
if (!is_directory())
return ENOTDIR;
@ -129,7 +129,7 @@ KResult TmpFSInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEnt
KResultOr<size_t> TmpFSInode::read_bytes(off_t offset, size_t size, UserOrKernelBuffer& buffer, FileDescription*) const
{
Locker locker(m_lock, Lock::Mode::Shared);
Locker locker(m_lock, Mutex::Mode::Shared);
VERIFY(!is_directory());
VERIFY(offset >= 0);
@ -198,7 +198,7 @@ KResultOr<size_t> TmpFSInode::write_bytes(off_t offset, size_t size, const UserO
RefPtr<Inode> TmpFSInode::lookup(StringView name)
{
Locker locker(m_lock, Lock::Mode::Shared);
Locker locker(m_lock, Mutex::Mode::Shared);
VERIFY(is_directory());
if (name == ".")
@ -214,7 +214,7 @@ RefPtr<Inode> TmpFSInode::lookup(StringView name)
KResultOr<size_t> TmpFSInode::directory_entry_count() const
{
Locker locker(m_lock, Lock::Mode::Shared);
Locker locker(m_lock, Mutex::Mode::Shared);
VERIFY(is_directory());
return 2 + m_children.size();
}

View file

@ -86,7 +86,7 @@ private:
Mount* find_mount_for_host(InodeIdentifier);
Mount* find_mount_for_guest(InodeIdentifier);
Lock m_lock { "VFSLock" };
Mutex m_lock { "VFSLock" };
RefPtr<Inode> m_root_inode;
Vector<Mount, 16> m_mounts;

View file

@ -31,7 +31,7 @@ class InodeWatcher;
class KBuffer;
class KResult;
class LocalSocket;
class Lock;
class Mutex;
class MappedROM;
class MasterPTY;
class Mount;

View file

@ -74,7 +74,7 @@ private:
virtual bool output(KBufferBuilder& builder) override
{
JsonArraySerializer array { builder };
Locker locker(arp_table().lock(), Lock::Mode::Shared);
Locker locker(arp_table().lock(), Mutex::Mode::Shared);
for (auto& it : arp_table().resource()) {
auto obj = array.add_object();
obj.add("mac_address", it.value.to_string());
@ -247,7 +247,7 @@ public:
private:
ProcFSDumpKmallocStacks();
mutable Lock m_lock;
mutable Mutex m_lock;
};
class ProcFSUBSanDeadly : public ProcFSSystemBoolean {
@ -266,7 +266,7 @@ public:
private:
ProcFSUBSanDeadly();
mutable Lock m_lock;
mutable Mutex m_lock;
};
class ProcFSCapsLockRemap : public ProcFSSystemBoolean {
@ -285,7 +285,7 @@ public:
private:
ProcFSCapsLockRemap();
mutable Lock m_lock;
mutable Mutex m_lock;
};
UNMAP_AFTER_INIT NonnullRefPtr<ProcFSDumpKmallocStacks> ProcFSDumpKmallocStacks::must_create(const ProcFSSystemDirectory&)

View file

@ -240,7 +240,7 @@ private:
// Synchronous commands
WaitQueue m_outstanding_request;
Lock m_operation_lock;
Mutex m_operation_lock;
OwnPtr<Region> m_scratch_space;
};

View file

@ -7,16 +7,16 @@
#include <AK/SourceLocation.h>
#include <Kernel/Debug.h>
#include <Kernel/KSyms.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/SpinLock.h>
#include <Kernel/Thread.h>
namespace Kernel {
#if LOCK_DEBUG
void Lock::lock(Mode mode, const SourceLocation& location)
void Mutex::lock(Mode mode, const SourceLocation& location)
#else
void Lock::lock(Mode mode)
void Mutex::lock(Mode mode)
#endif
{
// NOTE: This may be called from an interrupt handler (not an IRQ handler)
@ -30,7 +30,7 @@ void Lock::lock(Mode mode)
Mode current_mode = m_mode;
switch (current_mode) {
case Mode::Unlocked: {
dbgln_if(LOCK_TRACE_DEBUG, "Lock::lock @ ({}) {}: acquire {}, currently unlocked", this, m_name, mode_to_string(mode));
dbgln_if(LOCK_TRACE_DEBUG, "Mutex::lock @ ({}) {}: acquire {}, currently unlocked", this, m_name, mode_to_string(mode));
m_mode = mode;
VERIFY(!m_holder);
VERIFY(m_shared_holders.is_empty());
@ -71,9 +71,9 @@ void Lock::lock(Mode mode)
if constexpr (LOCK_TRACE_DEBUG) {
if (mode == Mode::Exclusive)
dbgln("Lock::lock @ {} ({}): acquire {}, currently exclusive, holding: {}", this, m_name, mode_to_string(mode), m_times_locked);
dbgln("Mutex::lock @ {} ({}): acquire {}, currently exclusive, holding: {}", this, m_name, mode_to_string(mode), m_times_locked);
else
dbgln("Lock::lock @ {} ({}): acquire exclusive (requested {}), currently exclusive, holding: {}", this, m_name, mode_to_string(mode), m_times_locked);
dbgln("Mutex::lock @ {} ({}): acquire exclusive (requested {}), currently exclusive, holding: {}", this, m_name, mode_to_string(mode), m_times_locked);
}
VERIFY(m_times_locked > 0);
@ -99,7 +99,7 @@ void Lock::lock(Mode mode)
m_mode = Mode::Exclusive;
m_holder = current_thread;
m_shared_holders.clear();
dbgln_if(LOCK_TRACE_DEBUG, "Lock::lock @ {} ({}): acquire {}, converted shared to exclusive lock, locks held {}", this, m_name, mode_to_string(mode), m_times_locked);
dbgln_if(LOCK_TRACE_DEBUG, "Mutex::lock @ {} ({}): acquire {}, converted shared to exclusive lock, locks held {}", this, m_name, mode_to_string(mode), m_times_locked);
return;
}
}
@ -109,7 +109,7 @@ void Lock::lock(Mode mode)
VERIFY(m_mode == mode);
}
dbgln_if(LOCK_TRACE_DEBUG, "Lock::lock @ {} ({}): acquire {}, currently shared, locks held {}", this, m_name, mode_to_string(mode), m_times_locked);
dbgln_if(LOCK_TRACE_DEBUG, "Mutex::lock @ {} ({}): acquire {}, currently shared, locks held {}", this, m_name, mode_to_string(mode), m_times_locked);
VERIFY(m_times_locked > 0);
if (m_mode == Mode::Shared) {
@ -143,7 +143,7 @@ void Lock::lock(Mode mode)
}
}
void Lock::unlock()
void Mutex::unlock()
{
// NOTE: This may be called from an interrupt handler (not an IRQ handler)
// and also from within critical sections!
@ -153,9 +153,9 @@ void Lock::unlock()
Mode current_mode = m_mode;
if constexpr (LOCK_TRACE_DEBUG) {
if (current_mode == Mode::Shared)
dbgln("Lock::unlock @ {} ({}): release {}, locks held: {}", this, m_name, mode_to_string(current_mode), m_times_locked);
dbgln("Mutex::unlock @ {} ({}): release {}, locks held: {}", this, m_name, mode_to_string(current_mode), m_times_locked);
else
dbgln("Lock::unlock @ {} ({}): release {}, holding: {}", this, m_name, mode_to_string(current_mode), m_times_locked);
dbgln("Mutex::unlock @ {} ({}): release {}, holding: {}", this, m_name, mode_to_string(current_mode), m_times_locked);
}
VERIFY(current_mode != Mode::Unlocked);
@ -200,21 +200,21 @@ void Lock::unlock()
}
}
void Lock::block(Thread& current_thread, Mode mode, ScopedSpinLock<SpinLock<u8>>& lock, u32 requested_locks)
void Mutex::block(Thread& current_thread, Mode mode, ScopedSpinLock<SpinLock<u8>>& lock, u32 requested_locks)
{
auto& blocked_thread_list = thread_list_for_mode(mode);
VERIFY(!blocked_thread_list.contains(current_thread));
blocked_thread_list.append(current_thread);
dbgln_if(LOCK_TRACE_DEBUG, "Lock::lock @ {} ({}) waiting...", this, m_name);
dbgln_if(LOCK_TRACE_DEBUG, "Mutex::lock @ {} ({}) waiting...", this, m_name);
current_thread.block(*this, lock, requested_locks);
dbgln_if(LOCK_TRACE_DEBUG, "Lock::lock @ {} ({}) waited", this, m_name);
dbgln_if(LOCK_TRACE_DEBUG, "Mutex::lock @ {} ({}) waited", this, m_name);
VERIFY(blocked_thread_list.contains(current_thread));
blocked_thread_list.remove(current_thread);
}
void Lock::unblock_waiters(Mode previous_mode)
void Mutex::unblock_waiters(Mode previous_mode)
{
VERIFY(m_times_locked == 0);
VERIFY(m_mode == Mode::Unlocked);
@ -253,7 +253,7 @@ void Lock::unblock_waiters(Mode previous_mode)
}
}
auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
auto Mutex::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
{
// NOTE: This may be called from an interrupt handler (not an IRQ handler)
// and also from within critical sections!
@ -268,7 +268,7 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
return Mode::Unlocked;
}
dbgln_if(LOCK_RESTORE_DEBUG, "Lock::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}", this, m_times_locked);
dbgln_if(LOCK_RESTORE_DEBUG, "Mutex::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}", this, m_times_locked);
#if LOCK_DEBUG
m_holder->holding_lock(*this, -(int)m_times_locked, {});
#endif
@ -288,7 +288,7 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
return Mode::Unlocked;
}
dbgln_if(LOCK_RESTORE_DEBUG, "Lock::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}, total locks: {}",
dbgln_if(LOCK_RESTORE_DEBUG, "Mutex::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}, total locks: {}",
this, it->value, m_times_locked);
VERIFY(it->value > 0);
@ -317,9 +317,9 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
}
#if LOCK_DEBUG
void Lock::restore_lock(Mode mode, u32 lock_count, const SourceLocation& location)
void Mutex::restore_lock(Mode mode, u32 lock_count, const SourceLocation& location)
#else
void Lock::restore_lock(Mode mode, u32 lock_count)
void Mutex::restore_lock(Mode mode, u32 lock_count)
#endif
{
VERIFY(mode != Mode::Unlocked);
@ -343,7 +343,7 @@ void Lock::restore_lock(Mode mode, u32 lock_count)
VERIFY(m_mode == Mode::Exclusive);
}
dbgln_if(LOCK_RESTORE_DEBUG, "Lock::restore_lock @ {}: restoring {} with lock count {}, was {}", this, mode_to_string(mode), lock_count, mode_to_string(previous_mode));
dbgln_if(LOCK_RESTORE_DEBUG, "Mutex::restore_lock @ {}: restoring {} with lock count {}, was {}", this, mode_to_string(mode), lock_count, mode_to_string(previous_mode));
VERIFY(m_mode != Mode::Shared);
VERIFY(m_shared_holders.is_empty());
@ -387,7 +387,7 @@ void Lock::restore_lock(Mode mode, u32 lock_count)
VERIFY(m_mode == Mode::Shared);
}
dbgln_if(LOCK_RESTORE_DEBUG, "Lock::restore_lock @ {}: restoring {} with lock count {}, was {}",
dbgln_if(LOCK_RESTORE_DEBUG, "Mutex::restore_lock @ {}: restoring {} with lock count {}, was {}",
this, mode_to_string(mode), lock_count, mode_to_string(previous_mode));
VERIFY(!m_holder);

View file

@ -16,20 +16,20 @@
namespace Kernel {
class Lock {
class Mutex {
friend class Thread;
AK_MAKE_NONCOPYABLE(Lock);
AK_MAKE_NONMOVABLE(Lock);
AK_MAKE_NONCOPYABLE(Mutex);
AK_MAKE_NONMOVABLE(Mutex);
public:
using Mode = LockMode;
Lock(const char* name = nullptr)
Mutex(const char* name = nullptr)
: m_name(name)
{
}
~Lock() = default;
~Mutex() = default;
#if LOCK_DEBUG
void lock(Mode mode = Mode::Exclusive, const SourceLocation& location = SourceLocation::current());
@ -108,9 +108,9 @@ private:
class Locker {
public:
#if LOCK_DEBUG
ALWAYS_INLINE explicit Locker(Lock& l, Lock::Mode mode = Lock::Mode::Exclusive, const SourceLocation& location = SourceLocation::current())
ALWAYS_INLINE explicit Locker(Mutex& l, Mutex::Mode mode = Mutex::Mode::Exclusive, const SourceLocation& location = SourceLocation::current())
#else
ALWAYS_INLINE explicit Locker(Lock& l, Lock::Mode mode = Lock::Mode::Exclusive)
ALWAYS_INLINE explicit Locker(Mutex& l, Mutex::Mode mode = Mutex::Mode::Exclusive)
#endif
: m_lock(l)
{
@ -134,9 +134,9 @@ public:
}
#if LOCK_DEBUG
ALWAYS_INLINE void lock(Lock::Mode mode = Lock::Mode::Exclusive, const SourceLocation& location = SourceLocation::current())
ALWAYS_INLINE void lock(Mutex::Mode mode = Mutex::Mode::Exclusive, const SourceLocation& location = SourceLocation::current())
#else
ALWAYS_INLINE void lock(Lock::Mode mode = Lock::Mode::Exclusive)
ALWAYS_INLINE void lock(Mutex::Mode mode = Mutex::Mode::Exclusive)
#endif
{
VERIFY(!m_locked);
@ -149,11 +149,11 @@ public:
#endif
}
Lock& get_lock() { return m_lock; }
const Lock& get_lock() const { return m_lock; }
Mutex& get_lock() { return m_lock; }
const Mutex& get_lock() const { return m_lock; }
private:
Lock& m_lock;
Mutex& m_lock;
bool m_locked { true };
};
@ -165,7 +165,7 @@ public:
: m_resource(move(resource))
{
}
[[nodiscard]] Lock& lock() { return m_lock; }
[[nodiscard]] Mutex& lock() { return m_lock; }
[[nodiscard]] T& resource() { return m_resource; }
[[nodiscard]] T lock_and_copy()
@ -176,7 +176,7 @@ public:
private:
T m_resource;
Lock m_lock;
Mutex m_lock;
};
class ScopedLockRelease {
@ -185,7 +185,7 @@ class ScopedLockRelease {
public:
ScopedLockRelease& operator=(ScopedLockRelease&&) = delete;
ScopedLockRelease(Lock& lock)
ScopedLockRelease(Mutex& lock)
: m_lock(&lock)
, m_previous_mode(lock.force_unlock_if_locked(m_previous_recursions))
{
@ -193,23 +193,23 @@ public:
ScopedLockRelease(ScopedLockRelease&& from)
: m_lock(exchange(from.m_lock, nullptr))
, m_previous_mode(exchange(from.m_previous_mode, Lock::Mode::Unlocked))
, m_previous_mode(exchange(from.m_previous_mode, Mutex::Mode::Unlocked))
, m_previous_recursions(exchange(from.m_previous_recursions, 0))
{
}
~ScopedLockRelease()
{
if (m_lock && m_previous_mode != Lock::Mode::Unlocked)
if (m_lock && m_previous_mode != Mutex::Mode::Unlocked)
m_lock->restore_lock(m_previous_mode, m_previous_recursions);
}
void restore_lock()
{
VERIFY(m_lock);
if (m_previous_mode != Lock::Mode::Unlocked) {
if (m_previous_mode != Mutex::Mode::Unlocked) {
m_lock->restore_lock(m_previous_mode, m_previous_recursions);
m_previous_mode = Lock::Mode::Unlocked;
m_previous_mode = Mutex::Mode::Unlocked;
m_previous_recursions = 0;
}
}
@ -217,13 +217,13 @@ public:
void do_not_restore()
{
VERIFY(m_lock);
m_previous_mode = Lock::Mode::Unlocked;
m_previous_mode = Mutex::Mode::Unlocked;
m_previous_recursions = 0;
}
private:
Lock* m_lock;
Lock::Mode m_previous_mode;
Mutex* m_lock;
Mutex::Mode m_previous_mode;
u32 m_previous_recursions;
};

View file

@ -10,7 +10,7 @@
#include <AK/SinglyLinkedListWithCount.h>
#include <Kernel/DoubleBuffer.h>
#include <Kernel/KBuffer.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/Net/IPv4.h>
#include <Kernel/Net/IPv4SocketTuple.h>
#include <Kernel/Net/Socket.h>

View file

@ -9,7 +9,7 @@
#include <AK/HashMap.h>
#include <Kernel/DoubleBuffer.h>
#include <Kernel/KBuffer.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/Net/IPv4.h>
#include <Kernel/Net/Socket.h>

View file

@ -26,7 +26,7 @@ static Lockable<LocalSocket::List>& all_sockets()
void LocalSocket::for_each(Function<void(const LocalSocket&)> callback)
{
Locker locker(all_sockets().lock(), Lock::Mode::Shared);
Locker locker(all_sockets().lock(), Mutex::Mode::Shared);
for (auto& socket : all_sockets().resource())
callback(socket);
}

View file

@ -5,7 +5,7 @@
*/
#include <Kernel/Debug.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/Net/ARP.h>
#include <Kernel/Net/EtherType.h>
#include <Kernel/Net/EthernetFrameHeader.h>
@ -224,7 +224,7 @@ void handle_icmp(const EthernetFrameHeader& eth, const IPv4Packet& ipv4_packet,
{
NonnullRefPtrVector<IPv4Socket> icmp_sockets;
{
Locker locker(IPv4Socket::all_sockets().lock(), Lock::Mode::Shared);
Locker locker(IPv4Socket::all_sockets().lock(), Mutex::Mode::Shared);
for (auto* socket : IPv4Socket::all_sockets().resource()) {
if (socket->protocol() != (unsigned)IPv4Protocol::ICMP)
continue;

View file

@ -40,7 +40,7 @@ private:
NonnullRefPtrVector<NetworkAdapter> m_adapters;
RefPtr<NetworkAdapter> m_loopback_adapter;
mutable Lock m_lock { "Networking" };
mutable Mutex m_lock { "Networking" };
};
}

View file

@ -12,7 +12,7 @@
#include <AK/Time.h>
#include <Kernel/FileSystem/File.h>
#include <Kernel/KResult.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/UnixTypes.h>
@ -99,7 +99,7 @@ public:
gid_t acceptor_gid() const { return m_acceptor.gid; }
const RefPtr<NetworkAdapter> bound_interface() const { return m_bound_interface; }
Lock& lock() { return m_lock; }
Mutex& lock() { return m_lock; }
// ^File
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override final;
@ -137,7 +137,7 @@ protected:
private:
virtual bool is_socket() const final { return true; }
Lock m_lock { "Socket" };
Mutex m_lock { "Socket" };
int m_domain { 0 };
int m_type { 0 };

View file

@ -23,7 +23,7 @@ namespace Kernel {
void TCPSocket::for_each(Function<void(const TCPSocket&)> callback)
{
Locker locker(sockets_by_tuple().lock(), Lock::Mode::Shared);
Locker locker(sockets_by_tuple().lock(), Mutex::Mode::Shared);
for (auto& it : sockets_by_tuple().resource())
callback(*it.value);
}
@ -68,7 +68,7 @@ Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>& TCPSocket::sockets_by_tuple()
RefPtr<TCPSocket> TCPSocket::from_tuple(const IPv4SocketTuple& tuple)
{
Locker locker(sockets_by_tuple().lock(), Lock::Mode::Shared);
Locker locker(sockets_by_tuple().lock(), Mutex::Mode::Shared);
auto exact_match = sockets_by_tuple().resource().get(tuple);
if (exact_match.has_value())
@ -91,7 +91,7 @@ RefPtr<TCPSocket> TCPSocket::create_client(const IPv4Address& new_local_address,
auto tuple = IPv4SocketTuple(new_local_address, new_local_port, new_peer_address, new_peer_port);
{
Locker locker(sockets_by_tuple().lock(), Lock::Mode::Shared);
Locker locker(sockets_by_tuple().lock(), Mutex::Mode::Shared);
if (sockets_by_tuple().resource().contains(tuple))
return {};
}
@ -545,7 +545,7 @@ void TCPSocket::retransmit_packets()
if (routing_decision.is_zero())
return;
Locker locker(m_not_acked_lock, Lock::Mode::Shared);
Locker locker(m_not_acked_lock, Mutex::Mode::Shared);
for (auto& packet : m_not_acked) {
packet.tx_counter++;

View file

@ -202,7 +202,7 @@ private:
int tx_counter { 0 };
};
mutable Lock m_not_acked_lock { "TCPSocket unacked packets" };
mutable Mutex m_not_acked_lock { "TCPSocket unacked packets" };
SinglyLinkedList<OutgoingPacket> m_not_acked;
size_t m_not_acked_size { 0 };

View file

@ -17,7 +17,7 @@ namespace Kernel {
void UDPSocket::for_each(Function<void(const UDPSocket&)> callback)
{
Locker locker(sockets_by_port().lock(), Lock::Mode::Shared);
Locker locker(sockets_by_port().lock(), Mutex::Mode::Shared);
for (auto it : sockets_by_port().resource())
callback(*it.value);
}
@ -33,7 +33,7 @@ SocketHandle<UDPSocket> UDPSocket::from_port(u16 port)
{
RefPtr<UDPSocket> socket;
{
Locker locker(sockets_by_port().lock(), Lock::Mode::Shared);
Locker locker(sockets_by_port().lock(), Mutex::Mode::Shared);
auto it = sockets_by_port().resource().find(port);
if (it == sockets_by_port().resource().end())
return {};

View file

@ -44,7 +44,7 @@ RecursiveSpinLock g_processes_lock;
static Atomic<pid_t> next_pid;
READONLY_AFTER_INIT Process::List* g_processes;
READONLY_AFTER_INIT String* g_hostname;
READONLY_AFTER_INIT Lock* g_hostname_lock;
READONLY_AFTER_INIT Mutex* g_hostname_lock;
READONLY_AFTER_INIT HashMap<String, OwnPtr<Module>>* g_modules;
READONLY_AFTER_INIT Region* g_signal_trampoline_region;
@ -66,7 +66,7 @@ UNMAP_AFTER_INIT void Process::initialize()
g_processes = new Process::List();
g_process_groups = new ProcessGroup::List();
g_hostname = new String("courage");
g_hostname_lock = new Lock;
g_hostname_lock = new Mutex;
create_signal_trampoline();
}

View file

@ -22,7 +22,7 @@
#include <Kernel/FileSystem/InodeMetadata.h>
#include <Kernel/Forward.h>
#include <Kernel/FutexQueue.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/PerformanceEventBuffer.h>
#include <Kernel/ProcessGroup.h>
#include <Kernel/StdLib.h>
@ -469,8 +469,8 @@ public:
return m_thread_count.load(AK::MemoryOrder::memory_order_relaxed);
}
Lock& big_lock() { return m_big_lock; }
Lock& ptrace_lock() { return m_ptrace_lock; }
Mutex& big_lock() { return m_big_lock; }
Mutex& ptrace_lock() { return m_ptrace_lock; }
Custody& root_directory();
Custody& root_directory_relative_to_global_root();
@ -696,8 +696,8 @@ private:
size_t m_master_tls_size { 0 };
size_t m_master_tls_alignment { 0 };
Lock m_big_lock { "Process" };
Lock m_ptrace_lock { "ptrace" };
Mutex m_big_lock { "Process" };
Mutex m_ptrace_lock { "ptrace" };
RefPtr<Timer> m_alarm_timer;

View file

@ -38,10 +38,10 @@ public:
void unregister_process(Process&);
ProcFSRootDirectory& root_folder() { return *m_root_folder; }
Lock& get_lock() { return m_lock; }
Mutex& get_lock() { return m_lock; }
private:
Lock m_lock;
Mutex m_lock;
NonnullRefPtr<ProcFSRootDirectory> m_root_folder;
};
@ -120,7 +120,7 @@ protected:
virtual bool acquire_link(KBufferBuilder& builder) = 0;
explicit ProcFSExposedLink(StringView name);
ProcFSExposedLink(StringView name, InodeIndex preallocated_index);
mutable Lock m_lock { "ProcFSLink" };
mutable Mutex m_lock { "ProcFSLink" };
};
class ProcFSProcessDirectory final

View file

@ -9,7 +9,7 @@
#include <AK/IntrusiveList.h>
#include <AK/RefCounted.h>
#include <AK/Weakable.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/SpinLock.h>
#include <Kernel/UnixTypes.h>

View file

@ -84,7 +84,7 @@ private:
{
}
WeakPtr<ProcFSProcessDirectory> m_process_folder;
mutable Lock m_lock;
mutable Mutex m_lock;
};
KResultOr<size_t> ProcFSProcessStacks::entries_count() const
@ -193,7 +193,7 @@ private:
{
}
WeakPtr<ProcFSProcessDirectory> m_process_folder;
mutable Lock m_lock;
mutable Mutex m_lock;
};
KResultOr<size_t> ProcFSProcessFileDescriptions::entries_count() const

View file

@ -10,7 +10,7 @@
#include <AK/Assertions.h>
#include <AK/ByteBuffer.h>
#include <AK/Types.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/StdLib.h>
#include <LibCrypto/Cipher/AES.h>
#include <LibCrypto/Cipher/Cipher.h>

View file

@ -11,7 +11,7 @@
#include <Kernel/Devices/Device.h>
#include <Kernel/IO.h>
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/Random.h>
#include <Kernel/Sections.h>
@ -102,7 +102,7 @@ private:
EntropySource m_entropy_source;
RefPtr<AsyncBlockDeviceRequest> m_current_request;
SpinLock<u8> m_hard_lock;
Lock m_lock { "AHCIPort" };
Mutex m_lock { "AHCIPort" };
mutable bool m_wait_for_completion { false };
bool m_wait_connect_for_completion { false };

View file

@ -11,7 +11,7 @@
#include <Kernel/Devices/Device.h>
#include <Kernel/IO.h>
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/Random.h>
#include <Kernel/Sections.h>

View file

@ -21,7 +21,7 @@
#include <Kernel/Devices/Device.h>
#include <Kernel/IO.h>
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/Random.h>
#include <Kernel/Storage/StorageDevice.h>
@ -158,7 +158,7 @@ protected:
u64 m_current_request_block_index { 0 };
bool m_current_request_flushing_cache { false };
SpinLock<u8> m_request_lock;
Lock m_lock { "IDEChannel" };
Mutex m_lock { "IDEChannel" };
IOAddressGroup m_io_group;
NonnullRefPtr<IDEController> m_parent_controller;

View file

@ -11,7 +11,7 @@
#pragma once
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/Storage/StorageDevice.h>
namespace Kernel {
@ -52,7 +52,7 @@ private:
bool is_slave() const;
Lock m_lock { "IDEDiskDevice" };
Mutex m_lock { "IDEDiskDevice" };
u16 m_capabilities { 0 };
NonnullRefPtr<IDEChannel> m_channel;
DriveType m_drive_type { DriveType::Master };

View file

@ -6,7 +6,7 @@
#pragma once
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/Storage/StorageDevice.h>
namespace Kernel {
@ -30,7 +30,7 @@ public:
bool is_slave() const;
Lock m_lock { "RamdiskDevice" };
Mutex m_lock { "RamdiskDevice" };
NonnullOwnPtr<Region> m_region;
};

View file

@ -7,7 +7,7 @@
#pragma once
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/Storage/AHCIPort.h>
#include <Kernel/Storage/StorageDevice.h>

View file

@ -12,7 +12,7 @@
#include <Kernel/Bus/PCI/DeviceController.h>
#include <Kernel/Devices/Device.h>
#include <Kernel/IO.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/Random.h>
#include <Kernel/VM/PhysicalPage.h>

View file

@ -8,7 +8,7 @@
#include <Kernel/Devices/BlockDevice.h>
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
#include <Kernel/Storage/Partition/DiskPartition.h>
#include <Kernel/Storage/StorageController.h>

View file

@ -9,14 +9,14 @@
namespace Kernel {
extern String* g_hostname;
extern Lock* g_hostname_lock;
extern Mutex* g_hostname_lock;
KResultOr<FlatPtr> Process::sys$gethostname(Userspace<char*> buffer, size_t size)
{
REQUIRE_PROMISE(stdio);
if (size > NumericLimits<ssize_t>::max())
return EINVAL;
Locker locker(*g_hostname_lock, Lock::Mode::Shared);
Locker locker(*g_hostname_lock, Mutex::Mode::Shared);
if (size < (g_hostname->length() + 1))
return ENAMETOOLONG;
if (!copy_to_user(buffer, g_hostname->characters(), g_hostname->length() + 1))
@ -29,7 +29,7 @@ KResultOr<FlatPtr> Process::sys$sethostname(Userspace<const char*> hostname, siz
REQUIRE_NO_PROMISES;
if (!is_superuser())
return EPERM;
Locker locker(*g_hostname_lock, Lock::Mode::Exclusive);
Locker locker(*g_hostname_lock, Mutex::Mode::Exclusive);
if (length > 64)
return ENAMETOOLONG;
auto copied_hostname = copy_string_from_user(hostname, length);

View file

@ -11,11 +11,11 @@ namespace Kernel {
KResultOr<FlatPtr> Process::sys$uname(Userspace<utsname*> user_buf)
{
extern String* g_hostname;
extern Lock* g_hostname_lock;
extern Mutex* g_hostname_lock;
REQUIRE_PROMISE(stdio);
Locker locker(*g_hostname_lock, Lock::Mode::Shared);
Locker locker(*g_hostname_lock, Mutex::Mode::Shared);
if (g_hostname->length() + 1 > sizeof(utsname::nodename))
return ENAMETOOLONG;

View file

@ -8,7 +8,7 @@
#include <AK/Badge.h>
#include <Kernel/Devices/CharacterDevice.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
namespace Kernel {
@ -43,7 +43,7 @@ private:
// ^CharacterDevice
virtual StringView class_name() const override { return "PTYMultiplexer"; }
Lock m_lock { "PTYMultiplexer" };
Mutex m_lock { "PTYMultiplexer" };
Vector<unsigned> m_freelist;
};

View file

@ -172,7 +172,7 @@ Thread::~Thread()
}
}
void Thread::block(Kernel::Lock& lock, ScopedSpinLock<SpinLock<u8>>& lock_lock, u32 lock_count)
void Thread::block(Kernel::Mutex& lock, ScopedSpinLock<SpinLock<u8>>& lock_lock, u32 lock_count)
{
VERIFY(!Processor::current().in_irq());
VERIFY(this == Thread::current());
@ -206,7 +206,7 @@ void Thread::block(Kernel::Lock& lock, ScopedSpinLock<SpinLock<u8>>& lock_lock,
lock_lock.unlock();
dbgln_if(THREAD_DEBUG, "Thread {} blocking on Lock {}", *this, &lock);
dbgln_if(THREAD_DEBUG, "Thread {} blocking on Mutex {}", *this, &lock);
auto& big_lock = process().big_lock();
for (;;) {
@ -238,7 +238,7 @@ void Thread::block(Kernel::Lock& lock, ScopedSpinLock<SpinLock<u8>>& lock_lock,
lock_lock.lock();
}
u32 Thread::unblock_from_lock(Kernel::Lock& lock)
u32 Thread::unblock_from_lock(Kernel::Mutex& lock)
{
ScopedSpinLock block_lock(m_block_lock);
VERIFY(m_blocking_lock == &lock);
@ -253,7 +253,7 @@ u32 Thread::unblock_from_lock(Kernel::Lock& lock)
VERIFY(g_scheduler_lock.own_lock());
VERIFY(m_block_lock.own_lock());
VERIFY(m_blocking_lock == &lock);
dbgln_if(THREAD_DEBUG, "Thread {} unblocked from Lock {}", *this, &lock);
dbgln_if(THREAD_DEBUG, "Thread {} unblocked from Mutex {}", *this, &lock);
m_blocking_lock = nullptr;
if (Thread::current() == this) {
set_state(Thread::Running);
@ -491,7 +491,7 @@ const char* Thread::state_string() const
case Thread::Blocked: {
ScopedSpinLock block_lock(m_block_lock);
if (m_blocking_lock)
return "Lock";
return "Mutex";
if (m_blocker)
return m_blocker->state_string();
VERIFY_NOT_REACHED();
@ -512,7 +512,7 @@ void Thread::finalize()
ScopedSpinLock list_lock(m_holding_locks_lock);
for (auto& info : m_holding_locks_list) {
const auto& location = info.source_location;
dbgln(" - Lock: \"{}\" @ {} locked in function \"{}\" at \"{}:{}\" with a count of: {}", info.lock->name(), info.lock, location.function_name(), location.filename(), location.line_number(), info.count);
dbgln(" - Mutex: \"{}\" @ {} locked in function \"{}\" at \"{}:{}\" with a count of: {}", info.lock->name(), info.lock, location.function_name(), location.filename(), location.line_number(), info.count);
}
VERIFY_NOT_REACHED();
}

View file

@ -116,7 +116,7 @@ class Thread
AK_MAKE_NONCOPYABLE(Thread);
AK_MAKE_NONMOVABLE(Thread);
friend class Lock;
friend class Mutex;
friend class Process;
friend class ProtectedProcessBase;
friend class Scheduler;
@ -824,7 +824,7 @@ public:
}
}
void block(Kernel::Lock&, ScopedSpinLock<SpinLock<u8>>&, u32);
void block(Kernel::Mutex&, ScopedSpinLock<SpinLock<u8>>&, u32);
template<typename BlockerType, class... Args>
[[nodiscard]] BlockResult block(const BlockTimeout& timeout, Args&&... args)
@ -957,7 +957,7 @@ public:
return result;
}
u32 unblock_from_lock(Kernel::Lock&);
u32 unblock_from_lock(Kernel::Mutex&);
void unblock_from_blocker(Blocker&);
void unblock(u8 signal = 0);
@ -1126,7 +1126,7 @@ public:
RecursiveSpinLock& get_lock() const { return m_lock; }
#if LOCK_DEBUG
void holding_lock(Lock& lock, int refs_delta, const SourceLocation& location)
void holding_lock(Mutex& lock, int refs_delta, const SourceLocation& location)
{
VERIFY(refs_delta != 0);
m_holding_locks.fetch_add(refs_delta, AK::MemoryOrder::memory_order_relaxed);
@ -1283,13 +1283,13 @@ private:
Optional<Range> m_thread_specific_range;
Array<SignalActionData, NSIG> m_signal_action_data;
Blocker* m_blocker { nullptr };
Kernel::Lock* m_blocking_lock { nullptr };
Kernel::Mutex* m_blocking_lock { nullptr };
u32 m_lock_requested_count { 0 };
IntrusiveListNode<Thread> m_blocked_threads_list_node;
#if LOCK_DEBUG
struct HoldingLockInfo {
Lock* lock;
Mutex* lock;
SourceLocation source_location;
unsigned count;
};

View file

@ -14,7 +14,7 @@
#include <AK/Vector.h>
#include <AK/Weakable.h>
#include <Kernel/Forward.h>
#include <Kernel/Lock.h>
#include <Kernel/Mutex.h>
namespace Kernel {
@ -70,7 +70,7 @@ protected:
IntrusiveListNode<VMObject> m_list_node;
FixedArray<RefPtr<PhysicalPage>> m_physical_pages;
Lock m_paging_lock { "VMObject" };
Mutex m_paging_lock { "VMObject" };
mutable SpinLock<u8> m_lock;