diff options
Diffstat (limited to 'Kernel/Lock.h')
-rw-r--r-- | Kernel/Lock.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Kernel/Lock.h b/Kernel/Lock.h index cfd69eb7f9..c0908dc136 100644 --- a/Kernel/Lock.h +++ b/Kernel/Lock.h @@ -41,7 +41,20 @@ public: void unlock(); [[nodiscard]] Mode force_unlock_if_locked(u32&); - [[nodiscard]] bool is_locked() const { return m_mode != Mode::Unlocked; } + [[nodiscard]] bool is_locked() const + { + ScopedSpinLock lock(m_lock); + return m_mode != Mode::Unlocked; + } + [[nodiscard]] bool own_lock() const + { + ScopedSpinLock lock(m_lock); + if (m_mode == Mode::Exclusive) + return m_holder == Thread::current(); + if (m_mode == Mode::Shared) + return m_shared_holders.contains(Thread::current()); + return false; + } [[nodiscard]] const char* name() const { return m_name; } @@ -89,7 +102,7 @@ private: BlockedThreadList m_blocked_threads_list_exclusive; BlockedThreadList m_blocked_threads_list_shared; - SpinLock<u8> m_lock; + mutable SpinLock<u8> m_lock; }; class Locker { |