This lecture covers OSC Chapter 3 (but not 3.5, 3.6 "POSIX Shared Memory", and it's fine to skip)
Pseudo machine life cycle kernel states kernel state memory layout
fork(): we copy the following, which is expensive
memory (text, data, stack): copy all
register: copy all but one (parent learns child's process ID, child gets 0)
io (file descriptor, stdin/stdout/stderr): copy all, also copy references to open-file state
other: timer state, current directory, umask
execve(): replace stack, heap, register, data, code, and some other kernel tracked process variables (like timer). This usually run by user after fork().
spawn()/posix_spawn(): fill out a large form (no need to copy, efficient)
Plan9 rfork()/linux clone(): specify which things is shared vs copied.
execve():
kernel transfer argv[], envp[] specified by execve() to top of new stack
hand-crafts stack frame for main
set registers (stack pointer, program counter)
scheduler states:
running: can be either user mode or kernel mode
blocked: can only be in kernel mode
runnable: can only be in kernel mode
forking: obsolete, used to cache program to swap disk when run out of memory during fork
zombie: process called exit() but parent hasn't noticed yet
exit(int reason)
SIGSEGV: hardware exception
SIGXCPU: software exception ("if I use too much CPU, execute me")
SIGUSR convention:
SIGUSR1: increase logging verbosity
SIGUSR2: decrease logging verbosity
SIGDANGER: Kernel hope program to give up memory.
garbage collector can use, but never because their job is to arrange memory efficiently but keep all avaliable memory.
db2: if you have clean page in some memory region, you can return them back to kernel
Release resources:
close() files
release memory
Accounting: record resource usage in file
Zombie: process state reduced to exit code, util parent calls wait(), process control block (PCB) deleted from kernel
process control block (PCB):
kernel datastructure in process table, which is in kernel memory space
stores everything about process


Minimum Kernel consists of:
getpid()
fork()
exec()
wait()
exit()
Table of Content