1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:57:35 +00:00

Kernel: Rename SpinLock => Spinlock

This commit is contained in:
Andreas Kling 2021-08-22 01:37:17 +02:00
parent 7d5d26b048
commit 55adace359
110 changed files with 491 additions and 491 deletions

View file

@ -8,7 +8,7 @@
#include <Kernel/KSyms.h>
#include <Kernel/Locking/LockLocation.h>
#include <Kernel/Locking/Mutex.h>
#include <Kernel/Locking/SpinLock.h>
#include <Kernel/Locking/Spinlock.h>
#include <Kernel/Thread.h>
namespace Kernel {
@ -21,7 +21,7 @@ void Mutex::lock(Mode mode, [[maybe_unused]] LockLocation const& location)
VERIFY(mode != Mode::Unlocked);
auto current_thread = Thread::current();
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
bool did_block = false;
Mode current_mode = m_mode;
switch (current_mode) {
@ -145,7 +145,7 @@ void Mutex::unlock()
// and also from within critical sections!
VERIFY(!Processor::current().in_irq());
auto current_thread = Thread::current();
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
Mode current_mode = m_mode;
if constexpr (LOCK_TRACE_DEBUG) {
if (current_mode == Mode::Shared)
@ -196,7 +196,7 @@ void Mutex::unlock()
}
}
void Mutex::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));
@ -255,7 +255,7 @@ auto Mutex::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
// and also from within critical sections!
VERIFY(!Processor::current().in_irq());
auto current_thread = Thread::current();
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
auto current_mode = m_mode;
switch (current_mode) {
case Mode::Exclusive: {
@ -319,7 +319,7 @@ void Mutex::restore_lock(Mode mode, u32 lock_count, [[maybe_unused]] LockLocatio
VERIFY(!Processor::current().in_irq());
auto current_thread = Thread::current();
bool did_block = false;
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
switch (mode) {
case Mode::Exclusive: {
auto previous_mode = m_mode;

View file

@ -39,12 +39,12 @@ public:
[[nodiscard]] Mode force_unlock_if_locked(u32&);
[[nodiscard]] bool is_locked() const
{
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
return m_mode != Mode::Unlocked;
}
[[nodiscard]] bool own_lock() const
{
ScopedSpinLock lock(m_lock);
ScopedSpinlock lock(m_lock);
if (m_mode == Mode::Exclusive)
return m_holder == Thread::current();
if (m_mode == Mode::Shared)
@ -77,7 +77,7 @@ private:
return mode == Mode::Exclusive ? m_blocked_threads_list_exclusive : m_blocked_threads_list_shared;
}
void block(Thread&, Mode, ScopedSpinLock<SpinLock<u8>>&, u32);
void block(Thread&, Mode, ScopedSpinlock<Spinlock<u8>>&, u32);
void unblock_waiters(Mode);
const char* m_name { nullptr };
@ -98,7 +98,7 @@ private:
BlockedThreadList m_blocked_threads_list_exclusive;
BlockedThreadList m_blocked_threads_list_shared;
mutable SpinLock<u8> m_lock;
mutable Spinlock<u8> m_lock;
};
class MutexLocker {

View file

@ -14,12 +14,12 @@
namespace Kernel {
template<typename BaseType = u32>
class SpinLock {
AK_MAKE_NONCOPYABLE(SpinLock);
AK_MAKE_NONMOVABLE(SpinLock);
class Spinlock {
AK_MAKE_NONCOPYABLE(Spinlock);
AK_MAKE_NONMOVABLE(Spinlock);
public:
SpinLock() = default;
Spinlock() = default;
ALWAYS_INLINE u32 lock()
{
@ -57,12 +57,12 @@ private:
Atomic<BaseType> m_lock { 0 };
};
class RecursiveSpinLock {
AK_MAKE_NONCOPYABLE(RecursiveSpinLock);
AK_MAKE_NONMOVABLE(RecursiveSpinLock);
class RecursiveSpinlock {
AK_MAKE_NONCOPYABLE(RecursiveSpinlock);
AK_MAKE_NONMOVABLE(RecursiveSpinlock);
public:
RecursiveSpinLock() = default;
RecursiveSpinlock() = default;
ALWAYS_INLINE u32 lock()
{
@ -116,15 +116,15 @@ private:
};
template<typename LockType>
class [[nodiscard]] ScopedSpinLock {
class [[nodiscard]] ScopedSpinlock {
AK_MAKE_NONCOPYABLE(ScopedSpinLock);
AK_MAKE_NONCOPYABLE(ScopedSpinlock);
public:
ScopedSpinLock() = delete;
ScopedSpinLock& operator=(ScopedSpinLock&&) = delete;
ScopedSpinlock() = delete;
ScopedSpinlock& operator=(ScopedSpinlock&&) = delete;
ScopedSpinLock(LockType& lock)
ScopedSpinlock(LockType& lock)
: m_lock(&lock)
{
VERIFY(m_lock);
@ -132,7 +132,7 @@ public:
m_have_lock = true;
}
ScopedSpinLock(ScopedSpinLock&& from)
ScopedSpinlock(ScopedSpinlock&& from)
: m_lock(from.m_lock)
, m_prev_flags(from.m_prev_flags)
, m_have_lock(from.m_have_lock)
@ -142,7 +142,7 @@ public:
from.m_have_lock = false;
}
~ScopedSpinLock()
~ScopedSpinlock()
{
if (m_lock && m_have_lock) {
m_lock->unlock(m_prev_flags);

View file

@ -6,14 +6,14 @@
#pragma once
#include <Kernel/Locking/SpinLock.h>
#include <Kernel/Locking/Spinlock.h>
namespace Kernel {
template<typename T>
class SpinLockProtected {
AK_MAKE_NONCOPYABLE(SpinLockProtected);
AK_MAKE_NONMOVABLE(SpinLockProtected);
class SpinlockProtected {
AK_MAKE_NONCOPYABLE(SpinlockProtected);
AK_MAKE_NONMOVABLE(SpinlockProtected);
private:
template<typename U>
@ -22,7 +22,7 @@ private:
AK_MAKE_NONMOVABLE(Locked);
public:
Locked(U& value, RecursiveSpinLock& spinlock)
Locked(U& value, RecursiveSpinlock& spinlock)
: m_value(value)
, m_locker(spinlock)
{
@ -39,14 +39,14 @@ private:
private:
U& m_value;
ScopedSpinLock<RecursiveSpinLock> m_locker;
ScopedSpinlock<RecursiveSpinlock> m_locker;
};
auto lock_const() const { return Locked<T const>(m_value, m_spinlock); }
auto lock_mutable() { return Locked<T>(m_value, m_spinlock); }
public:
SpinLockProtected() = default;
SpinlockProtected() = default;
template<typename Callback>
decltype(auto) with(Callback callback) const
@ -82,7 +82,7 @@ public:
private:
T m_value;
RecursiveSpinLock mutable m_spinlock;
RecursiveSpinlock mutable m_spinlock;
};
}