Difficulty: Easy
Correct Answer: 1
Explanation:
Introduction / Context:
Race conditions occur when multiple processes or threads access shared data concurrently and the final outcome depends on unpredictable interleavings. The critical section problem asks for a mechanism to ensure mutual exclusion so that shared state remains consistent. The fundamental safety requirement is that at most one process is executing the critical section at any instant.
Given Data / Assumptions:
Concept / Approach:
Mutual exclusion guarantees that only one process may enter the critical section at a time. This can be implemented with locks, semaphores, monitors, atomic instructions, or transactional memory. If two or more processes are allowed inside simultaneously, shared invariants can be violated, causing data corruption or inconsistent results. Therefore, the safe limit is a single process at any moment.
Step-by-Step Solution:
Verification / Alternative check:
Classical solutions (Peterson algorithm, bakery algorithm) and modern primitives all enforce the invariant that only one thread holds the lock at a time, preserving shared state consistency.
Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
1.
Discussion & Comments