The reader–writer problem coordinates shared access when readers may proceed together but writers require exclusive access. A meter simulation models technicians changing a value and loggers reading it. section 16.0 section 16.3.1
A practical synchronization design separates the access rules:
- Protect meter updates with a mutex so only one technician writes at a time. section 16.3.1
- Use a semaphore to permit up to three simultaneous logger reads while preventing writes during active reads. section 16.3.1
- Keep each read or write operation inside its critical region, including the simulated time spent accessing the meter. section 16.3.1
Meter simulation
Three technician threads repeatedly choose settings from 1 through 4 and update the meter. Three logger threads read and print the current setting; their output shows several loggers operating together between exclusive technician updates. section 16.3.1


