AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
fork.c File Reference

x86: the child's thread, for fork(). More...

#include <core/system.h>
#include <core/string.h>
#include <core/arch.h>
#include <sys/proc.h>
#include <sys/sched.h>
#include <aquila/errno.h>

Go to the source code of this file.

Functions

int arch_proc_fork (struct thread *thread, struct proc *fork)
 Sets up the CPU state of a fork() child's thread: a copy of the parent's kernel stack, registers and FPU state, so that the child returns from fork() as its parent does.

Detailed Description

x86: the child's thread, for fork().

Definition in file fork.c.

Function Documentation

◆ arch_proc_fork()

int arch_proc_fork ( struct thread * thread,
struct proc * fork )

Sets up the CPU state of a fork() child's thread: a copy of the parent's kernel stack, registers and FPU state, so that the child returns from fork() as its parent does.

Parameters
threadthe thread that called fork()
forkthe child process, whose one thread gets the state
Returns
0, or -ENOMEM if there was no memory for it

Definition at line 21 of file fork.c.

References thread::arch, arch_proc_fork(), x86_regs::err, x86_thread::fpu_context, x86_thread::fpu_enabled, queue::head, KERN_STACK_SIZE, kfree(), kmalloc(), x86_thread::kstack, x86_thread::kstack_base, M_ZERO, memcpy(), NULL, x86_thread::regs, x86_thread::rflags, x86_thread::rip, x86_thread::rsp, proc::threads, qnode::value, and x86_fpu_save_to().