Process
Definition
A process is a running program.
Machine State
The process's machine state consists of: memory, registers (including special registers like program counter), stack pointer, frame pointer
Process API
Create
Destroy
Wait
Miscellaneous Control: suspend, resume, ...
Status
Process Creation
- Load code and static data into memory

image.png
Allocate memory for the program's run-time stack
Create initial memory for the program's heap
Process States
Running
Ready
Blocked

image.png
UNIX Process API
fork()
Create a new process. For the parent process, returns the PID of the child process; for the child process, returns 0.
wait()
Wait for a child process to finish.
exec()
Run a program that is different from the calling program on the current process.
Motivating the API
The separation of fork() and exec() allows the shell to do things after fork() and before exec(), such as redirecting the input and output.