53#define FD_RESERVED ((struct file *) -1)
177void init_execve(
struct proc *
proc,
int argc,
char *
const argv[],
int envc,
char *
const envp[]);
207#define PROC_EXIT(info, code) ((((info) & 0xff) << 8) | ((code) & 0xff))
210#define PROC_UIO(proc) ((struct uio){.cwd = (proc)->cwd, .uid = (proc)->uid, .gid = (proc)->gid, .mask = (proc)->mask})
int proc_fd_get(struct proc *proc)
Reserves the lowest free descriptor of a process, while a system call sets it up: no other thread tak...
void proc_threads_exec(struct proc *proc)
Ends every thread of a process but the current one, for execve() (POSIX: they run in the program that...
void proc_dump(struct proc *proc)
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_reap(struct proc *proc)
Frees a zombie, once its parent waited for it (or doesn't wait for its children).
int proc_init(struct proc *proc)
Gives a new process (init) its ID and its descriptor table.
int proc_fork(struct thread *thread, struct proc **ref)
Makes a child process, a copy of the process of thread.
int proc_threads_end(struct proc *proc, struct thread *keep, int exiting)
Ends the threads of a process, but one.
int proc_execve(struct thread *thread, const char *fn, char *const argv[], char *const env[])
Runs another program in a thread's process, for execve().
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.
void proc_fd_release(struct proc *proc, int fd)
Frees a reserved descriptor that wasn't set up after all.
int pgrp_orphaned(struct pgroup *pgrp, struct proc *gone)
Says whether a process group is orphaned (POSIX): none of its members has a parent in another group o...
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...
struct proc * proc_pid_find(pid_t pid)
Finds a process by its ID.
int session_new(struct proc *proc)
Makes a new session, with a new process group, both led by a process and with its ID,...
void proc_fd_install(struct proc *proc, int fd, struct file *file, int flags)
Makes a reserved descriptor refer to an open file.
void init_execve(struct proc *proc, int argc, char *const argv[], int envc, char *const envp[])
Sets up init, the first process, to start its program: its initial stack with its arguments and envir...
int proc_setpgid(struct proc *proc, pid_t pgid)
Moves a process into a process group of its session, as setpgid() does.
void proc_kill(struct proc *proc)
Ends a process: its threads end, its descriptors are closed, its memory is freed, its children go to ...
void pgrp_release(struct pgroup *pgrp)
Frees a process group if no process is left in it, and its session if that was the session's last gro...
unsigned long long int uint64_t
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).
A link in a list, inside the structure that is listed.
A process group: the processes of a job.
struct proc * leader
its leader, the process whose PID is its ID
struct queue * procs
its processes
struct session * session
its session
struct qnode * session_node
its node on its session's list
struct waitq stop_queue
its stopped threads sleep here
pid_t pid
the process's ID
struct proc * parent
its parent
struct aquila_sigaction sigaction[SIG_MAX+1]
its signal actions
uint64_t utime
its CPU time in user mode and in the kernel (ns), and that of the children it waited for
struct waitq wait_queue
a parent waiting for a child (waitpid()) sleeps here
int tid_last
the last thread ID given out (threads leave in any order, so their count can't be the next one's ID)
struct vm_space vm_space
its address space
struct vm_entry * stack_vm
struct waitq thread_join
threads waiting in thread_join() sleep here
int exit
its exit status (PROC_EXIT())
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 list_node alarm_link
uint64_t alarm_at
its real time timer (ITIMER_REAL): SIGALRM when arch_rtime_ns() reaches alarm_at, then every alarm_in...
int stopped
the signal that stopped it, or 0; and what waitpid() has to report (WAIT_*)
struct vm_entry * heap_vm
its heap's and its stack's mappings
int running
whether it's running
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
sigset_t sig_pending
its pending signals, a bit (1 << sig) each: a signal sent again while it's pending is delivered once ...
struct pgroup * pgrp
its process group, and its node on the group's list
uintptr_t entry
its program's entry point
int zombie
proc_kill() is done with it, so it can be reaped (that isn't as soon as it stops running: closing its...
sigset_t sigmask
its blocked signals, a bit (1 << sig) each
A queue's node, holding one entry.
A session: its process groups, and its controlling terminal.
struct queue * pgps
its process groups
struct qnode * qnode
its node on the list of sessions
struct tty * ctty
its controlling terminal, or NULL
struct proc * leader
its leader, the process that made it
pid_t sid
the session's ID
A terminal, and its line discipline's state.
A mapping (map entry): a range of an address space, its permissions, and where its pages come from.
A file in memory (a vnode): what its inode says, and the kernel's own state.