Processes
Overview
This week introduces the process model — the fundamental abstraction for executing programs in an operating system.
Students will learn how processes are created, how they relate to one another, and how Linux represents and manages them.
We will also briefly explore virtual memory and its role in isolating processes, followed by the main system calls for creating and controlling processes.
By the end of this week, students will understand how programs become running processes, how parent and child processes interact, and how process management underpins multitasking in Linux.
Key Concepts
What is a Process?
- A process as an executing program instance
- Process attributes: PID, state, program counter, registers, open files
- Process lifecycle: creation → execution → termination
- Relationship between programs and processes
- Context switching overview
Virtual Memory (Brief Overview)
- Concept of process isolation
- Logical vs physical address spaces
- Paging: mapping memory in fixed-size blocks (pages)
- Role of MMU and page tables (at a high level)
- How virtual memory supports multitasking and protection
Process Hierarchy and Inheritance
- The process tree:
init/systemdas ancestor of all processes - Parent and child relationships
- Inheritance of environment variables and file descriptors
- Process groups and sessions
Process Creation and Execution
fork()— duplicating the current process- Return semantics of
fork()(0 in child, PID in parent) exec()family — replacing the current process imagegetpid(),getppid()— identifying process lineagewait()andwaitpid()— synchronizing process termination- Zombies and orphan processes
Practice / Lab
Exploring the Process Tree
- Use shell tools (
ps,pstree,top,htop) to inspect running processes. - Identify parent-child relationships and PIDs.
- Observe behavior when starting background jobs (
&) and pipelines.
Process Creation
- Write a simple program that spawns child processes using
fork(). - Observe execution order and differences in PID and PPID.
Executing New Programs
- Use
exec()to replace a process image and observe that it does not return. - Combine
fork()andexec()to launch external commands from your program.
Process Synchronization
- Use
wait()andwaitpid()to ensure orderly termination of child processes. - Observe zombie processes when a parent does not wait.
Homework
Samples
References & Resources
Required
- ECE 252 Lecture 4: Processes
- ECE 252 Lecture 5: Processes in UNIX
- The Exec Family of Functions
- The fork function in C
- Waiting for processes to finish in C
- Kerrisk, The Linux Programming Interface
- Chapter 24: Process Creation
- Chapter 25: Process Termination
- Chapter 26: Executing Programs
Recommended
- Linux manual page - fork(2)
- Linux manual page - wait(2)
- Linux manual page - clone(2)
- Linux manual page - exec(3)
- Example of fork() in C
- Fork System Call in Operating System
- Linux Processes and Threads (IBM Developer)
- Understanding
fork()andexec()(GeeksforGeeks) - The Process Tree (Red Hat Docs)
Quiz (Self-check)
- What is the difference between a program and a process?
- What does virtual memory achieve in process isolation?
- What are the main differences between
fork()andexec()? - What is inherited by a child process after
fork()? - What happens if a parent process never calls
wait()? - What is a zombie process, and how is it removed?
- How do
getpid()andgetppid()relate within a process tree?
Suggested Tools
ps,pstree,top,htop– inspect running processesstrace– tracefork,exec,waitsystem callspmap– display memory map of a processlsof– list open files for a given process