Understanding Processes and Threads: Core Concepts, Lifecycle, and Scheduling
This article explains operating system fundamentals such as process and thread definitions, time‑slice preemptive scheduling, process features and lifecycle, thread characteristics, priority handling, multi‑core execution models, and synchronization mechanisms like mutexes and semaphores.
Process and Thread Concepts
Operating systems like Windows and Linux use preemptive round‑robin scheduling, where each task runs for a short time slice before being paused for the next task. The running state is called "running" and the paused state is "ready", creating the illusion of concurrent execution.
Process
A process is an independent unit of execution that the OS schedules and allocates resources to. It consists of a program, its data, and a Process Control Block (PCB) that stores descriptive and control information.
Process Characteristics:
Dynamic: a temporary execution instance with a lifespan.
Concurrent: can run alongside other processes.
Independent: the OS treats it as a separate resource‑allocation unit.
Structured: composed of program, data, and PCB.
Early OSes defined five process states: created, ready, running, blocked (waiting), and exited.
Thread
Threads are the smallest unit of program execution and the basic unit of CPU scheduling. A process may contain one or many threads, which share the process's memory space.
Standard Thread Components: thread ID, program counter (PC), registers, and stack.
Thread Lifecycle
When the number of threads is less than the number of processors, threads run truly concurrently on separate cores. Otherwise, the OS time‑slices threads, creating simulated concurrency.
Thread states mirror process states: created, ready, running, blocked, and exited.
Thread Priority
Operating systems also use priority scheduling; higher‑priority threads run before lower‑priority ones. Priorities can be set manually or adjusted by the OS based on I/O‑bound versus CPU‑bound behavior.
Priority changes occur via:
User‑specified priority.
OS‑adjusted priority based on wait frequency.
Priority boost after prolonged waiting (to prevent starvation). Thread Starvation Low‑priority threads may starve if higher‑priority threads dominate CPU time. OSes mitigate this by gradually raising the priority of waiting threads.
Multithreading and Multicore
Modern CPUs integrate multiple cores, each capable of true parallel execution. Kernel threads (KLT) are directly supported by the OS and map to physical or logical cores. Thread models:
One‑to‑One Model: each user thread maps to a unique kernel thread, providing true concurrency but limited by kernel thread count and context‑switch overhead.
Many‑to‑One Model: many user threads share a single kernel thread, offering fast switches but blocking all threads if one blocks.
Many‑to‑Many Model: multiple user threads map to multiple kernel threads, combining benefits of both models while allowing many user threads.
Differences Between Processes and Threads
Process: OS resource‑allocation unit; thread: smallest execution unit.
Threads share a process's memory and resources; processes are isolated.
Thread context switches are faster than process switches.
Synchronization Mechanisms
Mutual exclusion (mutex) ensures exclusive access to a shared resource, analogous to a single‑key lock. A semaphore generalizes this concept, allowing up to n concurrent accesses, similar to a set of keys for a room that can hold n people.
Operating System Design Goals
Support multiple processes to run simultaneously.
Support multithreading within a single process.
Provide coordination mechanisms to avoid conflicts while allowing resource sharing.
Original source: http://luckylau.tech/2017/06/20/%E8%BF%9B%E7%A8%8B%E5%92%8C%E7%BA%BF%E7%A8%8B%E7%9A%84%E5%8C%BA%E5%88%AB/ (author: Luckylau)
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
