Which semaphore-based synchronization approach would you choose to maximize throughput and why?
hard🌍 Real-world Scenario Q9 of Q15
Operating Systems - Producer-Consumer Problem Using Semaphores
You are designing a high-throughput logging system where multiple producers generate log entries and a single consumer writes them to disk. Which semaphore-based synchronization approach would you choose to maximize throughput and why?
AUse a single mutex protecting the buffer without counting semaphores to minimize overhead
BUse counting semaphores for empty/full slots and a mutex, but batch consumer consumption to reduce lock contention
CUse busy waiting on semaphores to ensure immediate processing of log entries
DUse separate mutexes for each producer to allow concurrent buffer access
Use a single mutex protecting the buffer without counting semaphores to minimize overhead risks buffer overflow/underflow; C wastes CPU; D risks race conditions without proper coordination.
Final Answer:
Option B -> Option B
Quick Check:
Counting semaphores plus batching maximize throughput safely [OK]