From 12474addda872a42d904db303089002c4d2bd8a8 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 7 Dec 2023 13:19:12 +0200 Subject: [PATCH] Kernel: Make Inodes use the new lock Also remove old lock from TTY since it can just use the one Inode already has. --- kernel/include/kernel/FS/Inode.h | 5 +++-- kernel/include/kernel/Terminal/TTY.h | 2 -- kernel/kernel/Terminal/TTY.cpp | 8 ++++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/kernel/include/kernel/FS/Inode.h b/kernel/include/kernel/FS/Inode.h index 4cdc16e370..2d4520a622 100644 --- a/kernel/include/kernel/FS/Inode.h +++ b/kernel/include/kernel/FS/Inode.h @@ -121,9 +121,10 @@ namespace Kernel virtual BAN::ErrorOr chmod_impl(mode_t) { return BAN::Error::from_errno(ENOTSUP); } virtual bool has_data_impl() const { dwarnln("nonblock not supported"); return true; } - private: - mutable RecursiveSpinLock m_lock; + protected: + mutable RecursivePrioritySpinLock m_lock; + private: BAN::WeakPtr m_shared_region; friend class FileBackedRegion; }; diff --git a/kernel/include/kernel/Terminal/TTY.h b/kernel/include/kernel/Terminal/TTY.h index 9c776167e8..2f3c5a37f8 100644 --- a/kernel/include/kernel/Terminal/TTY.h +++ b/kernel/include/kernel/Terminal/TTY.h @@ -56,8 +56,6 @@ namespace Kernel void do_backspace(); protected: - mutable Kernel::RecursiveSpinLock m_lock; - TerminalDriver::Color m_foreground { TerminalColor::BRIGHT_WHITE }; TerminalDriver::Color m_background { TerminalColor::BLACK }; termios m_termios; diff --git a/kernel/kernel/Terminal/TTY.cpp b/kernel/kernel/Terminal/TTY.cpp index bcfd14c794..bf8ffc4eb6 100644 --- a/kernel/kernel/Terminal/TTY.cpp +++ b/kernel/kernel/Terminal/TTY.cpp @@ -303,9 +303,13 @@ namespace Kernel LockGuard _(m_lock); while (!m_output.flush) { - m_lock.unlock(); + // FIXME: this is very hacky way to unlock lock temporarily + uint32_t depth = m_lock.lock_depth(); + for (uint32_t i = 0; i < depth; i++) + m_lock.unlock(); bool eintr = Thread::current().block_or_eintr(m_output.semaphore); - m_lock.lock(); + for (uint32_t i = 0; i < depth; i++) + m_lock.lock(); if (eintr) return BAN::Error::from_errno(EINTR); }