mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +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
|
@ -119,6 +119,7 @@ public:
|
|||
int sys$uname(utsname*);
|
||||
int sys$readlink(const char*, char*, size_t);
|
||||
int sys$ttyname_r(int fd, char*, size_t);
|
||||
pid_t sys$fork(RegisterDump&);
|
||||
|
||||
static void initialize();
|
||||
|
||||
|
@ -155,11 +156,13 @@ public:
|
|||
|
||||
void send_signal(int signal, Process* sender);
|
||||
|
||||
Process* fork(RegisterDump&);
|
||||
|
||||
private:
|
||||
friend class MemoryManager;
|
||||
friend bool scheduleNewProcess();
|
||||
|
||||
Process(String&& name, uid_t, gid_t, pid_t parentPID, RingLevel, RetainPtr<VirtualFileSystem::Node>&& cwd = nullptr, RetainPtr<VirtualFileSystem::Node>&& executable = nullptr, TTY* = nullptr);
|
||||
Process(String&& name, uid_t, gid_t, pid_t parentPID, RingLevel, RetainPtr<VirtualFileSystem::Node>&& cwd = nullptr, RetainPtr<VirtualFileSystem::Node>&& executable = nullptr, TTY* = nullptr, Process* fork_parent = nullptr);
|
||||
|
||||
void allocateLDT();
|
||||
|
||||
|
@ -183,8 +186,6 @@ private:
|
|||
State m_state { Invalid };
|
||||
DWORD m_wakeupTime { 0 };
|
||||
TSS32 m_tss;
|
||||
word m_ldt_selector { 0 };
|
||||
Descriptor* m_ldtEntries { nullptr };
|
||||
Vector<OwnPtr<FileHandle>> m_file_descriptors;
|
||||
RingLevel m_ring { Ring0 };
|
||||
int m_error { 0 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue