1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 14:55:08 +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

@ -85,8 +85,8 @@ KResultOr<pid_t> Process::sys$fork(RegisterState& regs)
{
ScopedSpinLock lock(space().get_lock());
for (auto& region : space().regions()) {
dbgln_if(FORK_DEBUG, "fork: cloning Region({}) '{}' @ {}", &region, region.name(), region.vaddr());
auto region_clone = region.clone(*child);
dbgln_if(FORK_DEBUG, "fork: cloning Region({}) '{}' @ {}", region, region->name(), region->vaddr());
auto region_clone = region->clone(*child);
if (!region_clone) {
dbgln("fork: Cannot clone region, insufficient memory");
// TODO: tear down new process?
@ -96,7 +96,7 @@ KResultOr<pid_t> Process::sys$fork(RegisterState& regs)
auto& child_region = child->space().add_region(region_clone.release_nonnull());
child_region.map(child->space().page_directory(), ShouldFlushTLB::No);
if (&region == m_master_tls_region.unsafe_ptr())
if (region == m_master_tls_region.unsafe_ptr())
child->m_master_tls_region = child_region;
}