1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 09:54:57 +00:00

Kernel: Replace process' regions vector with a Red Black tree

This should provide some speed up, as currently searches for regions
containing a given address were performed in O(n) complexity, while
this container allows us to do those in O(logn).
This commit is contained in:
Idan Horowitz 2021-04-07 02:20:29 +03:00 committed by Andreas Kling
parent 497c759ab7
commit 2c93123daf
7 changed files with 89 additions and 97 deletions

View file

@ -433,13 +433,8 @@ Region* MemoryManager::kernel_region_from_vaddr(VirtualAddress vaddr)
Region* MemoryManager::user_region_from_vaddr(Space& space, VirtualAddress vaddr)
{
// FIXME: Use a binary search tree (maybe red/black?) or some other more appropriate data structure!
ScopedSpinLock lock(space.get_lock());
for (auto& region : space.regions()) {
if (region.contains(vaddr))
return &region;
}
return nullptr;
return space.find_region_containing({ vaddr, 1 });
}
Region* MemoryManager::find_region_from_vaddr(Space& space, VirtualAddress vaddr)