This repository demonstrates a wide range of POSIX multithreading concepts through hands-on examples in C and C++ on Linux systems. It's structured into two partsβFoundations (Part A) and Advanced Concepts (Part B)βto help you gain a solid and practical understanding of multithreading.
π‘ This repository was built while following a comprehensive Udemy course on Multithreading. If you're interested, you can check out the course here.
This section introduces core concepts and provides simple, practical programs to get started.
-
Thread Management
Creating threads, terminating them, managing thread stack memory, and understanding thread scheduling. -
Concurrency vs Parallelism
Differences between singularism, concurrency, and parallelism with real-world analogies. -
Joinable vs Detached Threads
Implementation and use cases with practical examples like a map-reduce model. -
Inter-Thread Communication (ITC)
Concepts such as callbacks, notification chains, and publisher-subscriber models. -
Thread Synchronization
Managing shared resources using mutexes, condition variables, and critical sections. -
Classic Synchronization Problems
Solutions for standard problems like:- Producer-Consumer
- Dining Philosophers
-
Semaphores
Basics, usage, and how they differ from mutexes.
π All examples are available in the Part-A/ directory.
Take your skills further with in-depth explorations and custom implementations.
-
Recursive Mutexes
When and how to use them. -
Read-Write Locks
Advantages and custom implementation. -
Monitors
Using monitors to structure thread-safe operations. -
Assembly Line Pattern
Designing concurrent workflows for real-world applications. -
Deadlock Detection and Prevention
Techniques to identify and avoid deadlocks. -
Wait Queues & Thread Pools
Efficient multithreading task management patterns. -
Bonus Concepts
Including:- Bounded Waiting
- Strong Semaphores
- Event Pair Synchronization
π These examples can be found in the Part-B/ directory.
If this project helped you understand POSIX multithreading better, consider β starring the repo to support the work!
π Ready to go deeper? Explore the accompanying Udemy course here.