1. Introduction
Every time you open a browser, run a Python script, or type a command in the terminal, the operating system (OS) creates a process to carry out that work. A process is the single most important abstraction the OS provides: it is a program in execution. Modern programs often do many things at once (a browser downloads a file while rendering a page and playing a video); to support this the OS gives each process one or more threads, the smallest units the CPU actually schedules.
For BCS, Bank IT, and IT-officer exams this topic is a guaranteed source of questions — definitions ("what is a process?"), the difference between process and program, the difference between process and thread, the process state diagram and its transitions, the Process Control Block (PCB), context switching, and short numeric problems on multithreading and context-switch overhead. Master this lesson and you can answer almost any OS question on processes and threads.
2. Learning Objectives
After studying this lesson you should be able to:
- Define a program, a process, and a thread, and clearly distinguish them.
- Describe the parts of a process in memory (text, data, heap, stack) and the contents of a Process Control Block (PCB).
- Draw and explain the 5-state (and 7-state) process state diagram and every transition.
- Explain context switching and why it is pure overhead.
- Distinguish user-level threads from kernel-level threads and describe multithreading models.
- Solve numeric problems on context-switch cost, degree of multiprogramming, and thread memory.
- Avoid the classic exam traps (process vs. thread confusion, "running to ready" vs. "running to blocked", etc.).