Difficulty: Easy
Correct Answer: Critical section
Explanation:
Introduction / Context:
Concurrent programs require coordination when accessing shared data. The code segments that manipulate shared state must be protected to prevent interleavings that cause inconsistent results, known as race conditions.
Given Data / Assumptions:
Concept / Approach:
The term “critical section” denotes the code region that requires mutual exclusion. Mechanisms such as locks, semaphores, monitors, and atomic operations enforce that only one thread executes the critical section at a time.
Step-by-Step Solution:
Identify the shared data structure (e.g., queue, counter).Wrap its access within a critical section.Use a synchronization primitive (e.g., mutex, binary semaphore) to enforce mutual exclusion.Release the primitive upon exiting to permit progress of other threads.
Verification / Alternative check:
Testing under high concurrency should show absence of data races and consistent results when the critical section is correctly protected.
Why Other Options Are Wrong:
Semaphores (Option A) are a mechanism, not the code region itself.Directory (Option B) is unrelated to concurrency control.Mutual exclusion (Option D) is the property or technique, not the region’s name.
Common Pitfalls:
Final Answer:
Critical section.
Discussion & Comments