Skip to content
System Programming
Processes

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/systemd as 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 image
  • getpid(), getppid() — identifying process lineage
  • wait() and waitpid() — 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() and exec() to launch external commands from your program.

Process Synchronization

  • Use wait() and waitpid() to ensure orderly termination of child processes.
  • Observe zombie processes when a parent does not wait.

Homework


Samples


References & Resources

Required

Recommended


Quiz (Self-check)

  1. What is the difference between a program and a process?
  2. What does virtual memory achieve in process isolation?
  3. What are the main differences between fork() and exec()?
  4. What is inherited by a child process after fork()?
  5. What happens if a parent process never calls wait()?
  6. What is a zombie process, and how is it removed?
  7. How do getpid() and getppid() relate within a process tree?

Suggested Tools

  • ps, pstree, top, htop – inspect running processes
  • strace – trace fork, exec, wait system calls
  • pmap – display memory map of a process
  • lsof – list open files for a given process