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

aarch64: fork()'s child thread, which returns to user mode as its parent does, from a copy of its parent's saved registers at the top of its own kernel stack. 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

struct aarch64_thread * aarch64_thread_new (void)
 Makes a thread's aarch64 state, with its kernel stack.
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

aarch64: fork()'s child thread, which returns to user mode as its parent does, from a copy of its parent's saved registers at the top of its own kernel stack.

Definition in file fork.c.

Function Documentation

◆ aarch64_thread_new()

struct aarch64_thread * aarch64_thread_new ( void )

Makes a thread's aarch64 state, with its kernel stack.

Returns
the state, or NULL if there was no memory for it

Definition at line 30 of file thread.c.

References aarch64_thread_new(), KERN_STACK_SIZE, kfree(), kmalloc(), aarch64_thread::kstack, aarch64_thread::kstack_base, M_ZERO, and NULL.

Referenced by aarch64_thread_new(), arch_kthread_create(), arch_proc_fork(), arch_proc_init(), and arch_thread_create().

◆ 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 aarch64_fpsimd_fork(), aarch64_thread_new(), thread::arch, arch_proc_fork(), aarch64_thread::ctx, aarch64_ctx::fp, queue::head, kfree(), aarch64_thread::kstack, aarch64_thread::kstack_base, aarch64_ctx::lr, aarch64_thread::regs, aarch64_ctx::sp, proc::threads, and qnode::value.

Referenced by arch_proc_fork(), and proc_fork().