summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AK/Lock.h25
-rw-r--r--AK/test.cpp2
-rw-r--r--Kernel/DoubleBuffer.h2
-rw-r--r--Kernel/IDEDiskDevice.h2
-rw-r--r--Kernel/PTYMultiplexer.h2
-rw-r--r--Kernel/Process.h4
-rw-r--r--VirtualFileSystem/Ext2FileSystem.h4
-rw-r--r--WindowServer/WSEventLoop.h2
-rw-r--r--WindowServer/WSWindowManager.h2
9 files changed, 18 insertions, 27 deletions
diff --git a/AK/Lock.h b/AK/Lock.h
index 93fe8f82c6..acc4b84a53 100644
--- a/AK/Lock.h
+++ b/AK/Lock.h
@@ -12,12 +12,6 @@ extern Process* current;
#error This thing is kernel-only right now.
#endif
-//#define DEBUG_LOCKS
-
-void log_try_lock(const char*);
-void log_locked(const char*);
-void log_unlocked(const char*);
-
namespace AK {
static inline dword CAS(volatile dword* mem, dword newval, dword oldval)
@@ -31,17 +25,14 @@ static inline dword CAS(volatile dword* mem, dword newval, dword oldval)
return ret;
}
-// FIXME: Rename to YieldingLock? RecursiveLock? Maybe just Lock?
-class SpinLock {
+class Lock {
public:
- SpinLock() { }
- ~SpinLock() { }
+ Lock() { }
+ ~Lock() { }
void lock();
void unlock();
- const Process* holder() const { return m_holder; }
-
private:
volatile dword m_lock { 0 };
dword m_level { 0 };
@@ -50,16 +41,16 @@ private:
class Locker {
public:
- ALWAYS_INLINE explicit Locker(SpinLock& l) : m_lock(l) { lock(); }
+ ALWAYS_INLINE explicit Locker(Lock& l) : m_lock(l) { lock(); }
ALWAYS_INLINE ~Locker() { unlock(); }
ALWAYS_INLINE void unlock() { m_lock.unlock(); }
ALWAYS_INLINE void lock() { m_lock.lock(); }
private:
- SpinLock& m_lock;
+ Lock& m_lock;
};
-inline void SpinLock::lock()
+inline void Lock::lock()
{
for (;;) {
if (CAS(&m_lock, 1, 0) == 0) {
@@ -76,7 +67,7 @@ inline void SpinLock::lock()
}
}
-inline void SpinLock::unlock()
+inline void Lock::unlock()
{
for (;;) {
if (CAS(&m_lock, 1, 0) == 0) {
@@ -101,5 +92,5 @@ inline void SpinLock::unlock()
}
-using AK::SpinLock;
+using AK::Lock;
using AK::Locker;
diff --git a/AK/test.cpp b/AK/test.cpp
index 8945eb599a..5690fb8fb5 100644
--- a/AK/test.cpp
+++ b/AK/test.cpp
@@ -23,7 +23,7 @@ int main(int c, char** v)
StringImpl::initialize_globals();
{
- SpinLock lock;
+ Lock lock;
Locker locker(lock);
}
diff --git a/Kernel/DoubleBuffer.h b/Kernel/DoubleBuffer.h
index 7c3c0be4c3..bc1efc0ac9 100644
--- a/Kernel/DoubleBuffer.h
+++ b/Kernel/DoubleBuffer.h
@@ -30,5 +30,5 @@ private:
Vector<byte> m_buffer2;
size_t m_read_buffer_index { 0 };
bool m_empty { true };
- SpinLock m_lock;
+ Lock m_lock;
};
diff --git a/Kernel/IDEDiskDevice.h b/Kernel/IDEDiskDevice.h
index 1a70ba995b..6db024bb95 100644
--- a/Kernel/IDEDiskDevice.h
+++ b/Kernel/IDEDiskDevice.h
@@ -37,7 +37,7 @@ private:
bool read_sectors(dword start_sector, word count, byte* buffer);
bool write_sectors(dword start_sector, word count, const byte* data);
- SpinLock m_lock;
+ Lock m_lock;
word m_cylinders { 0 };
word m_heads { 0 };
word m_sectors_per_track { 0 };
diff --git a/Kernel/PTYMultiplexer.h b/Kernel/PTYMultiplexer.h
index 4646fc7f05..fe91f6eb34 100644
--- a/Kernel/PTYMultiplexer.h
+++ b/Kernel/PTYMultiplexer.h
@@ -19,6 +19,6 @@ public:
virtual bool can_write(Process&) const override { return true; }
private:
- SpinLock m_lock;
+ Lock m_lock;
Vector<RetainPtr<MasterPTY>> m_freelist;
};
diff --git a/Kernel/Process.h b/Kernel/Process.h
index 8d8238dccb..eddd71ba29 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -254,7 +254,7 @@ public:
bool is_root() const { return m_euid == 0; }
Vector<GUI_Event>& gui_events() { return m_gui_events; }
- SpinLock& gui_events_lock() { return m_gui_events_lock; }
+ Lock& gui_events_lock() { return m_gui_events_lock; }
bool wakeup_requested() { return m_wakeup_requested; }
void request_wakeup() { m_wakeup_requested = true; }
@@ -358,7 +358,7 @@ private:
HashMap<int, OwnPtr<WSWindow>> m_windows;
Vector<GUI_Event> m_gui_events;
- SpinLock m_gui_events_lock;
+ Lock m_gui_events_lock;
int m_next_window_id { 1 };
dword m_wakeup_requested { false };
diff --git a/VirtualFileSystem/Ext2FileSystem.h b/VirtualFileSystem/Ext2FileSystem.h
index a9c279c3af..6ac87333bb 100644
--- a/VirtualFileSystem/Ext2FileSystem.h
+++ b/VirtualFileSystem/Ext2FileSystem.h
@@ -47,7 +47,7 @@ private:
const Ext2FS& fs() const;
Ext2FSInode(Ext2FS&, unsigned index, const ext2_inode&);
- SpinLock m_lock;
+ Lock m_lock;
Vector<unsigned> m_block_list;
HashMap<String, unsigned> m_lookup_cache;
ext2_inode m_raw_inode;
@@ -110,7 +110,7 @@ private:
mutable ByteBuffer m_cached_super_block;
mutable ByteBuffer m_cached_group_descriptor_table;
- mutable SpinLock m_inode_cache_lock;
+ mutable Lock m_inode_cache_lock;
mutable HashMap<BlockIndex, RetainPtr<Ext2FSInode>> m_inode_cache;
};
diff --git a/WindowServer/WSEventLoop.h b/WindowServer/WSEventLoop.h
index e7695d8070..c4e914df49 100644
--- a/WindowServer/WSEventLoop.h
+++ b/WindowServer/WSEventLoop.h
@@ -29,7 +29,7 @@ private:
void drain_mouse();
void drain_keyboard();
- SpinLock m_lock;
+ Lock m_lock;
struct QueuedEvent {
WSEventReceiver* receiver { nullptr };
diff --git a/WindowServer/WSWindowManager.h b/WindowServer/WSWindowManager.h
index 58be90b8d6..abfc432ee6 100644
--- a/WindowServer/WSWindowManager.h
+++ b/WindowServer/WSWindowManager.h
@@ -92,5 +92,5 @@ private:
OwnPtr<Painter> m_back_painter;
OwnPtr<Painter> m_front_painter;
- mutable SpinLock m_lock;
+ mutable Lock m_lock;
};