mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 14:55:08 +00:00
Implement fork()!
This is quite cool! The syscall entry point plumbs the register dump down to sys$fork(), which uses it to set up the child process's TSS in order to resume execution right after the int 0x80 fork() call. :^) This works pretty well, although there is some problem with the kernel alias mappings used to clone the parent process's regions. If I disable the MM::release_page_directory() code, there's no problem. Probably there's a premature freeing of a physical page somehow.
This commit is contained in:
parent
10b666f69a
commit
8accc92c3c
16 changed files with 228 additions and 78 deletions
|
@ -407,3 +407,23 @@ bool MemoryManager::validate_user_write(const Process& process, LinearAddress la
|
|||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
RetainPtr<Region> Region::clone()
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
KernelPagingScope pagingScope;
|
||||
|
||||
// FIXME: Implement COW regions.
|
||||
auto clone_zone = MM.createZone(zone->size());
|
||||
auto clone_region = adopt(*new Region(linearAddress, size, move(clone_zone), String(name)));
|
||||
|
||||
// FIXME: It would be cool to make the src_alias a read-only mapping.
|
||||
byte* src_alias = MM.create_kernel_alias_for_region(*this);
|
||||
byte* dest_alias = MM.create_kernel_alias_for_region(*clone_region);
|
||||
|
||||
memcpy(dest_alias, src_alias, size);
|
||||
|
||||
MM.remove_kernel_alias_for_region(*clone_region, dest_alias);
|
||||
MM.remove_kernel_alias_for_region(*this, src_alias);
|
||||
return clone_region;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue