<aside>
💡
Summary of Section 5.1 - Process Interactions
</aside>
Process Competition
- Concurrency occurs when multiple processes (or threads) execute simultaneously. This can happen:
- In parallel if multiple CPUs are available.
- Through time-sharing on a single CPU.
- Critical Sections:
- A critical section (CS) is a segment of code that must not be accessed by multiple processes simultaneously.
- If two processes access shared data without protection, it may result in inconsistencies.
- Critical Section Problem:
- Incorrect interleaving of instructions can lead to unexpected results (e.g., lost updates to shared data).
- Requirements for a Correct CS Solution:
- Mutual exclusion – Only one process is allowed in the CS at a time.
- Lockout prevention – Non-participating processes should not prevent access.
- Starvation prevention – No process should be indefinitely denied access.
- Deadlock prevention – Processes should not block each other indefinitely.
Software Solution for the Critical Section Problem
- Uses variables (c1, c2, will_wait) to control access.
- If both processes request the CS simultaneously, a tie-breaking mechanism (will_wait) ensures progress.
- Incorrect solutions can lead to:
- Lockout (one process is permanently denied access).
- Deadlock (both processes wait indefinitely).
- Failure to ensure mutual exclusion (both enter CS at once).
Process Cooperation
- Some processes must work together rather than compete.
- Producer-Consumer Synchronization:
- A producer generates data.
- A consumer processes it.
- Proper synchronization ensures:
- The consumer does not read empty buffers.
- The producer does not overwrite unprocessed data.
Exercises and Key Questions
- Understanding interleaving effects on shared data.
- Evaluating critical section failures in various solutions.
- Analyzing the interactions between producer and consumer processes.
[End of Notes, Message #1]