mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +00:00
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.
This commit is contained in:
parent
363cc12146
commit
a6a439243f
94 changed files with 235 additions and 259 deletions
|
@ -22,7 +22,7 @@ public:
|
|||
void reclaim_space(PhysicalAddress chunk_start, size_t chunk_size);
|
||||
PhysicalAddress start_of_used() const;
|
||||
|
||||
Spinlock& lock() { return m_lock; }
|
||||
Spinlock<LockRank::None>& lock() { return m_lock; }
|
||||
size_t used_bytes() const { return m_num_used_bytes; }
|
||||
PhysicalAddress start_of_region() const { return m_region->physical_page(0)->paddr(); }
|
||||
VirtualAddress vaddr() const { return m_region->vaddr(); }
|
||||
|
@ -32,7 +32,7 @@ private:
|
|||
RingBuffer(NonnullOwnPtr<Memory::Region> region, size_t capacity);
|
||||
|
||||
NonnullOwnPtr<Memory::Region> m_region;
|
||||
Spinlock m_lock { LockRank::None };
|
||||
Spinlock<LockRank::None> m_lock {};
|
||||
size_t m_start_of_used {};
|
||||
size_t m_num_used_bytes {};
|
||||
size_t m_capacity_in_bytes {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue