This chapter covers the concepts of threads, concurrency, and parallelism in operating systems. It explains the advantages of using threads, different multithreading models, and how threads are implemented in operating systems like Linux. Examples in C are provided to illustrate thread creation and management using POSIX threads (Pthreads).
Table of Contents
- Introduction to Threads
- Single vs. Multithreaded Processes
- Advantages of Threads
- Concurrency vs. Parallelism
- Multicore Programming
- Amdahl’s Law
- User and Kernel Threads
- Multithreading Models
- Thread Libraries
- POSIX Threads (Pthreads) in C
Introduction to Threads
- A thread is the smallest unit of CPU utilization within a process.
- Threads allow multiple sequences of programmed instructions to run concurrently within a single process.
- Threads consist of:
- Thread ID
- Program Counter
- Set of Registers
- Stack
- Threads share other components of the process, such as code, data, and files.
Single vs. Multithreaded Processes
- Single-threaded Process: Has only one thread of control.