
Explore why expensive process creation can hinder performance by showing a web server cloning child processes to service many requests in parallel, and highlight the overhead.
Compare single threaded and multithreaded processes, showing how threads share code, data, and system resources within a process while each thread maintains its own registers, stack, and program counter.
Explore the POSIX thread (pthreads) API for portable multithreading, including thread creation, synchronization, and linking with -lpthread on unix-like systems.
Create a new thread with pthread_create by passing a function and its argument, with default attributes, while the main thread continues and the OS schedules them in no guaranteed order.
Pass thread arguments by defining a structure for A and B, allocate it dynamically, cast to a void pointer for thread creation, and reclaim memory after use.
Use pthread_self to obtain a thread's own ID, and pthread_equal to compare thread IDs for correctness and portability in multi-threaded programs.
Explore how threads terminate in multithreading with four paths: thread function completion, pthread_exit, pthread_cancel, and process termination, and understand asynchronous, synchronous, and uncontrollable cancellation.
Approach 2 for the too much milk problem uses symmetric thread logic with notes. It can fail under heavy interleaving, causing a liveness violation where no milk is bought.
Demonstrate how two threads can deadlock by acquiring two locks in opposite orders, then show how enforcing a consistent lock order prevents deadlock in the critical section.
Learn how busy waiting wastes CPU cycles and can cause priority-based deadlock, and how semaphores provide a cleaner signaling method that blocks waiting threads.
Explore how multithreaded programs yield different outputs due to operating system thread scheduling, and learn to detect risk conditions, deadlocks, and starvation with tests or Hal Grind for posix threading.
Learn how multithreading exploits true parallelism on multi-core systems, and why proper workload distribution and avoiding blocking or dependencies are essential for scalable gains.
Explore how multithreading boosts responsiveness and cpu utilization on single-core and multi-core systems by keeping cores busy with ready threads during io waits and cache misses.
Replace per-request thread creation with a thread pool of fixed worker threads that fetch tasks from a task queue, reducing latency and preventing resource exhaustion.
Explore massively parallel supercomputing, where thousands of general‑purpose cpus communicate via message passing to share data and synchronize, while minimizing inter‑cpu communication and maximizing bandwidth for nearby task placement.
Explore the readers-writers problem, a classic synchronization challenge, and learn to allow multiple readers while granting a single writer access to a shared dataset to prevent data races.
Learn how the readers-writers problem handles a shared dataset with two semaphores, read count tracking, and mutexes to coordinate readers and writers in the critical section.
Examine how a reader process uses a read count, mutex and read write mutex to safely enter and exit the critical section, ensuring mutual exclusion with writers.
Explain how readers have priority in the readers-writers problem, and how writer priority can be achieved by blocking new readers until no writers wait.
Explore the resource allocation graph to identify cycles and determine the presence or absence of deadlock. Trace the finishing order where processes release resources to allow others to complete.
Explore many-to-many threading, where many user threads map onto a fixed pool of kernel threads, and the two-level model binds select threads 1-to-1. Most systems favor 1-to-1 mappings for performance.
Ace multithreading, Pthreads, synchronization, locks, semaphores, concurrency, deadlocks questions in competitive exams, job interviews, and OS course exams.
Do you know: A single-threaded process can only execute on one core even if the machine has eight cores? A multithreaded process can exploit the true hardware parallelism! What are data races? What is process synchronization? What are atomic operations? How to implement correct multithreaded programs without data races? What are locks and semaphores? How do we use locks and semaphores to implement correct synchronization solutions? What are deadlocks? What are the necessary conditions for deadlocks? How do operating systems deal with deadlocks? How do operating systems implement threads? How do operating systems implement locks to ensure correct mutual exclusion and synchronization? Learn the explanations to these and many more intriguing questions in this course!
Specifically, the course will cover the following in detail.
Why use threads in programs?
What are the overheads of using processes?
What is the key idea behind threads?
Difference between single vs multithreaded processes.
Benefits of using threads.
Pthread basics.
How to create a thread using Pthread?
How to pass parameters to a thread?
How to use Pthread_self, Pthread_equal?
How to terminate a thread?
How to use Pthread_join to wait for a thread to terminate?
How to return values from thread functions?
How to wait for threads?
How to detach a thread using Pthread_detach?
What are global variables in threads?
What is concurrency in programs?
What are race conditions and atomic operations?
What is synchronization?
What are the correctness properties for synchronization solutions?
How to enforce mutual exclusion?
What are locks?
How to use locks in Pthreads?
How to avoid deadlock with locks?
What are semaphores?
What are synchronization patterns--bounded concurrent access, signaling?
How to employ semaphores to avoid busy waiting?
How multithreading interacts with multicores?
What are the challenges of multicore programming?
How to designing multithreaded programs?
What are thread pools?
What is the readers-writers problem?
How to solve the readers-writers problem?
What is the dining philosophers problem?
How to solve the dining philosophers problem?
What are the 4 necessary conditions for deadlocks?
How to prevent deadlocks?
What is resource allocation graph?
How to handle deadlocks?
How to implement threads?
What are user threads and kernel threads?
How are threads implemented in Linux?
How are locks implemented?
What is the TestAndSet atomic instruction?
What are spin locks?
How do locks influence performance?
30 day money back guaranteed by Udemy.
Wisdom scholarships. If you are interested in taking one of our courses but cannot purchase it, you can apply for a scholarship to enroll. Learn more about the application process at my website.