Bird
Raised Fist0

If the buffer size in a producer-consumer system is increased dynamically at runtime, which challenge arises that the classic semaphore-based solution does NOT handle well?

hard🎤 Interviewer Follow-up Q15 of Q15
Operating Systems - Producer-Consumer Problem Using Semaphores
If the buffer size in a producer-consumer system is increased dynamically at runtime, which challenge arises that the classic semaphore-based solution does NOT handle well?
AConsumers must signal the 'empty' semaphore twice per consumed item
BThe 'empty' semaphore count must be adjusted atomically to reflect new buffer slots
CProducers will never block because buffer is always large enough
DMutex locks become ineffective with dynamic buffer sizes
Step-by-Step Solution
  1. Step 1: Classic solution assumes fixed buffer size

    Semaphore 'empty' initialized once to buffer size; dynamic resizing breaks this assumption.
  2. Step 2: Adjusting semaphore counts

    When buffer grows, 'empty' semaphore must be incremented atomically to reflect new slots; otherwise, producers may block unnecessarily.
  3. Step 3: Why other options are incorrect

    Consumers must signal the 'empty' semaphore twice per consumed item is false; consumers do not signal 'empty' twice. Mutex locks become ineffective with dynamic buffer sizes is false; mutex still protects critical section regardless of size. Producers will never block because buffer is always large enough is false; producers can still block if buffer is full.
  4. Final Answer:

    Option B -> Option B
  5. Quick Check:

    Dynamic buffer size requires careful semaphore count updates [OK]
Quick Trick: Dynamic buffer size requires dynamic semaphore adjustment
Common Mistakes:
MISTAKES
  • Assuming fixed semaphore counts suffice for dynamic buffers
  • Thinking mutex depends on buffer size
  • Misunderstanding producer blocking conditions
Trap Explanation:
PITFALL
  • Candidates often overlook that semaphore counts must reflect actual resource availability; dynamic resizing breaks static initialization assumptions.
Interviewer Note:
CONTEXT
  • Tests advanced understanding of limitations and extensions of classic producer-consumer synchronization
Master "Producer-Consumer Problem Using Semaphores" in Operating Systems

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Operating Systems Quizzes