From a6a439243f3101e5d2f75f54b8aa6bc4c8b2e323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Wed, 9 Nov 2022 11:39:58 +0100 Subject: Kernel: Turn lock ranks into template parameters This step would ideally not have been necessary (increases amount of refactoring and templates necessary, which in turn increases build times), but it gives us a couple of nice properties: - SpinlockProtected inside Singleton (a very common combination) can now obtain any lock rank just via the template parameter. It was not previously possible to do this with SingletonInstanceCreator magic. - SpinlockProtected's lock rank is now mandatory; this is the majority of cases and allows us to see where we're still missing proper ranks. - The type already informs us what lock rank a lock has, which aids code readability and (possibly, if gdb cooperates) lock mismatch debugging. - The rank of a lock can no longer be dynamic, which is not something we wanted in the first place (or made use of). Locks randomly changing their rank sounds like a disaster waiting to happen. - In some places, we might be able to statically check that locks are taken in the right order (with the right lock rank checking implementation) as rank information is fully statically known. This refactoring even more exposes the fact that Mutex has no lock rank capabilites, which is not fixed here. --- Kernel/FileSystem/Mount.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Kernel/FileSystem/Mount.cpp') diff --git a/Kernel/FileSystem/Mount.cpp b/Kernel/FileSystem/Mount.cpp index 733147d746..b123b78ddc 100644 --- a/Kernel/FileSystem/Mount.cpp +++ b/Kernel/FileSystem/Mount.cpp @@ -14,7 +14,7 @@ namespace Kernel { Mount::Mount(FileSystem& guest_fs, Custody* host_custody, int flags) : m_guest(guest_fs.root_inode()) , m_guest_fs(guest_fs) - , m_host_custody(LockRank::None, host_custody) + , m_host_custody(host_custody) , m_flags(flags) { } @@ -22,7 +22,7 @@ Mount::Mount(FileSystem& guest_fs, Custody* host_custody, int flags) Mount::Mount(Inode& source, Custody& host_custody, int flags) : m_guest(source) , m_guest_fs(source.fs()) - , m_host_custody(LockRank::None, host_custody) + , m_host_custody(host_custody) , m_flags(flags) { } -- cgit v1.2.3