mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:58:11 +00:00
Region::clone() should share the zone if it's read-only.
This avoids copying the .text and .rodata segments in fork(). The next step is copy-on-write support for the writable regions.
This commit is contained in:
parent
da13c9a264
commit
7fe4063323
1 changed files with 4 additions and 0 deletions
|
@ -428,6 +428,10 @@ RetainPtr<Region> Region::clone()
|
|||
InterruptDisabler disabler;
|
||||
KernelPagingScope pagingScope;
|
||||
|
||||
if (is_readable && !is_writable) {
|
||||
// Create a new region backed by the same zone.
|
||||
return adopt(*new Region(linearAddress, size, zone.copyRef(), String(name), is_readable, is_writable));
|
||||
}
|
||||
// FIXME: Implement COW regions.
|
||||
auto clone_zone = MM.createZone(zone->size());
|
||||
auto clone_region = adopt(*new Region(linearAddress, size, move(clone_zone), String(name), is_readable, is_writable));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue