19#include <aquila/errno.h>
148 pvm_node = pvm_node->
next;
149 fvm_node = fvm_node->
next;
189 while ((_thread = dequeue(&fork->
threads)))
198 queue_remove(
procs, 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,...
void arch_syscall_return(struct thread *thread, uintptr_t val)
Sets the result of a thread's system call, in the register that returns it to user mode.
int vfs_close(struct vnode *vnode)
Drops a reference to a vnode.
struct file * file_ref(struct file *file)
Adds a reference to an open file.
void * kmalloc(size_t size, struct malloc_type *type, int flags)
Allocates memory for one of the kernel's structures.
#define MALLOC_DECLARE(type)
void kfree(void *)
Frees an object that kmalloc() gave.
void * memcpy(void *dst, const void *src, size_t n)
Copies n bytes; dst and src must not overlap.
void pmap_decref(struct pmap *pmap)
Drops a reference to an address space's page tables, freeing them with the last one.
int proc_fd_close(struct proc *proc, int fd)
Closes a descriptor: it is free again, and its reference to the open file is dropped.
void proc_pid_free(int pid)
Frees a process ID.
int proc_fork(struct thread *thread, struct proc **ref)
Makes a child process, a copy of the process of thread.
struct file * proc_fd_file(struct proc *proc, int fd)
Finds the open file a descriptor refers to.
pid_t proc_pid_alloc(void)
Allocates a process ID, from 1 (init's) on.
int proc_new(struct proc **ref)
Makes a new process structure, with one thread and an empty address space, on the list of every proce...
A file descriptor: the open file it refers to (fs/file.c, shared with the descriptors that dup() and ...
An open file (POSIX's "open file description", fs/file.c).
struct queue * procs
its processes
pid_t pid
the process's ID
struct proc * parent
its parent
struct aquila_sigaction sigaction[SIG_MAX+1]
its signal actions
struct vm_space vm_space
its address space
struct vm_entry * stack_vm
struct vnode * cwd
its current directory (a reference), or NULL for the root
uintptr_t heap_start
where its heap starts, and where it ends now (sbrk())
struct vm_entry * heap_vm
its heap's and its stack's mappings
struct fd * fds
its file descriptors (FDS_COUNT of them)
mode_t mask
its file mode creation mask (umask)
char * name
its name: the program it runs
uid_t uid
its user and group IDs
struct queue threads
its threads
struct pgroup * pgrp
its process group, and its node on the group's list
uintptr_t entry
its program's entry point
sigset_t sigmask
its blocked signals, a bit (1 << sig) each
A queue's node, holding one entry.
int spawned
whether it has run yet
struct proc * owner
its process
A mapping (map entry): a range of an address space, its permissions, and where its pages come from.
struct pmap * pmap
its page tables (the architecture's)
struct queue vm_entries
its mappings (map entries), in address order
size_t ref
how many references there are to it
static int copy_fds(struct proc *parent, struct proc *fork)
Copies the parent's descriptors to the child.
static int fork_proc_copy(struct proc *parent, struct proc *fork)
Copies what the child inherits from the parent's process structure: its process group,...
int vm_space_fork(struct vm_space *parent, struct vm_space *child)
Copies an address space's mappings into another, for fork().
void vm_space_destroy(struct vm_space *vm_space)
Removes all the mappings of an address space: its entries are released and freed, and its page tables...