Do I need to protect a variable written in one thread and read by many?

I am writing a data collection system. The system also processes fast data from our signal digitizers and slow control / monitoring for things like a high voltage system for detectors. The slow control system reads voltages once per second and writes them to the data structure.

Each event is marked with voltage for its detector before writing to disk. To do this, event processing threads read the structure written by the slow control / monitoring stream.

Given that it doesn’t matter if the event that occurred X microseconds after reading the voltage was noted by the sign of the previous second voltage: Do I need to worry about the mutex to protect the data structure or atomic variables in the structure?

+4
source share
2 answers

If I understand correctly, every second thread reads voltage, writes it to some "data structure", and other threads read from this data structure from time to time (am I right?)

" " (int, char .. x86, ), , , , ( , ). , , / / , .

" " - undefined, .

" " , , , .

" " , std::atomic . , , -, .

+6

, , , . - , ( , , Intel)

+2

All Articles