
Advance to master multithreaded design patterns in C/C++ using posix threads. Explore thread management, pools, barriers, monitors, and producer–consumer synchronization with practical, advanced examples.
Define a thread data structure and prototype three APIs for a multithreaded library, then implement create, run, and a general or dance mode toggle to initialize and start threads.
Learn how to pause and resume pthreads using mutex and condition variables, including cancellation points and building custom apis, while avoiding invariance and resource leaks.
Take a learning break to explore the globalist linked list as a new approach, using it as a supporting data structure for future assignments with a working implementation.
Explore thread pool data structures and apis for implementing multithreading design patterns. Build a linked list based thread pool with mutex protection and management apis for adding or removing threads.
Begin implementing a pthreads thread pool by initializing the pool, inserting and fetching threads with a mutex-protected linked list, and starting the dispatch logic while integrating the dual thread library.
Learn to implement a pthreads thread pool API: enqueue threads into the pool, block them on a condition variable, then dispatch by creating the execution unit or signaling the thread.
Demonstrates a thread pool by creating and initializing two threads, dispatching functions that print even and odd numbers in reverse and normal order, with sleeps.
Implement step seven as an optional notification from the worker thread to the application. A boolean flag decides whether the application blocks; use zero semaphores, with condition variables as an alternative.
Understand barrier synchronization in multithreaded programs: a barrier threshold blocks threads at a barrier point until the required number arrives, then releases all and transitions through disposition until completion.
Compare the test_and_wait API with the standard two-state locking procedure, mapping lock mutex, predicate check, block on the condition variable, wake, recheck, enter the critical section, and unlock.
Implement and initialize wait queues in a pthreads-based multithreading design patterns course, wiring up data structures, APIs, and three-step signaling with mutexes and condition variables.
Design a traffic light data structure with color and direction enumerations, implement a traffic light phase, manage per-face mutex and wait queues, and expose initialization and status APIs.
Model moving traffic with threads approaching traffic light faces, using per-phase wait queues and mutexes, plus thread private data and state enumeration to block on red and resume on green.
Explain what recursive mutexes are, why they prevent deadlocks by allowing the same thread to lock multiple times, and how to enable and use them with POSIX mutex attributes.
Explore when to use recursive mutexes in multithreaded software, showing how nested API locks can deadlock with normal mutexes and how recursive locks enable safe re-entry.
Explore Reed Wright locks and mutex concepts, review in-built API support, examine use cases, then write your own implementation to gain conceptual clarity.
Learn to implement a read-write lock from scratch, ensuring reader and writer coordination, support for recursion, correct unlock semantics, and crash-on-invalid unlock, using only condition variables and mutexes.
Learn to implement a read-write lock using a state mutex, a condition variable, and counters to manage access and ownership by readers and writers.
Explore how monitors generalize read-write locks to coordinate threads, enabling customizable cooperation schemes and problem-specific synchronization for multithreading with pthreads.
Upgrade the rewrite lock to a monitor by applying five customizations, making the read-write lock configurable, and setting up a monitor directory for upcoming changes.
Implement the replacement property in a pthreads monitor by updating the unlock API to signal waiting readers and writers, achieving symmetric read and write locking.
This is a sequel Course to Master Class-Multithreading & Thread Synchronization - C/C++, and this course should be done only when the prequel course has been completed unless you have reasonable knowledge regarding how Mutexes and Condition Variables work.
In this course, we shall be Implementing Advanced Thread Synchronization Data Structures and Multithreading based software patterns, with some advanced thread synchronization-based problem-solving. This course uses POSIX threads, hence it is Linux only course. We shall be building upon the knowledge we gathered from the prequel course.
*** However note that the course is highly conceptual and concepts learned can be easily applied to any programming knowledge which supports Multithreading. *** So, Java, C#, Python, Go, Kotlin Programmers do not hesitate to enroll in this course, you can write your own codes based on the concept discussed. This Course is unique and only one of its kind.
The level of this course is Intermediate to Advanced.
Table of Contents
====================
1. Thread Management
2. Pausing and Resuming Threads
3. Thread Pools/Work Crew Model
4. Thread Barriers
5. Wait-Queue Model
6. Recursive Mutexes
What are Recursive Mutexes?
When to use over Normal Mutexes?
Implement own Recursive Mutex
7. Read-Write Locks
What are Read-Write locks ?
What is its benefit?
Implement your own Read-Write lock
8. Monitors
Implement Reader-Writer Monitor
Solving Bridge Problem using Monitors
Guidelines for writing Monitors
Case Study : Covid Vaccination Drive Implementation using Monitors
*** Completed Till here as of 2 Mar 2022 **
9. Assembly Line Model
10. Deadlock Detection and Prevention
11. Other Related Courses on Multi-Threading
Designing Timers
Designing Multi-Threaded TCP Servers
Asynchronous Programming
UnScheduled Topics :
=================
11. Bounded Waiting
12. Fifo (Strong) Semaphores
13. Event Pair Synchronization
14. Inter-Process Synchronization using Semaphores
15. Forking a Multi-Threaded Program
Though We use the C language to demonstrate the concepts, concepts hold good for any programming language. This course is equally valuable for C++ programmers. Other language programmers may also find this course useful as we explain Multithreading concepts close to the ground zero levels with No Abstraction.
At each stage of this Course series, you shall be writing a lot of multi-threaded Codes. So be ready to Master the Multi-threading. Along the journey, we shall cover several interview-favorite topics and Questions to prepare you alongside for interviews.