Process Synchronization
Dr. Noman Islam
Producer Consumer problem
Producer
Consumer
Interleaving of instructions
Structure of a process with critical section
Requirements for a critical section
1. Mutual exclusion. If process Pi is executing in its critical section, then no other processes can be executing in their critical sections.
2. Progress. If no process is executing in its critical section and some processes wish to enter their critical sections, then only those processes that are not executing in their remainder sections can participate in deciding which will enter its critical section next, and this selection cannot be postponed indefinitely.
3. Bounded waiting. There exists a bound, or limit, on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted.
Non-preemptive kernel
Peterson’s solution
Synchronization hardware
Mutex Locks
Semaphores
Semaphore implementation
Deadlock and starvation
Bounded buffer problem
Readers writers problem
Dining philosopher problem
Solution to dining philosopher problem
Monitors