Bird
0
0

In designing thread-safe systems, why is it critical to keep the locked section (critical section) as short as possible?

hard📝 Conceptual Q10 of 15
LLD - Advanced LLD Concepts
In designing thread-safe systems, why is it critical to keep the locked section (critical section) as short as possible?
ATo reduce contention and improve overall system throughput
BTo ensure locks are held for maximum time to prevent race conditions
CTo allow threads to skip acquiring locks when not needed
DTo increase the complexity of synchronization logic
Step-by-Step Solution
Solution:
  1. Step 1: Understand lock scope

    The critical section is the code protected by a lock to ensure thread safety.
  2. Step 2: Effects of lock duration

    Long lock durations increase contention, causing threads to wait longer and reducing concurrency.
  3. Step 3: Benefits of short critical sections

    Short critical sections minimize waiting time, improving throughput and responsiveness.
  4. Final Answer:

    To reduce contention and improve overall system throughput -> Option A
  5. Quick Check:

    Short locks reduce contention and boost throughput [OK]
Quick Trick: Short critical sections reduce contention [OK]
Common Mistakes:
  • Believing longer locks improve safety
  • Ignoring performance impact of lock duration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes