This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Caching globals in registers


On Sun, Nov 05, 2017 at 08:30:01PM +0100, jacob navia wrote:
> Suppose (one of the multiple scenarios) that you store in a set of memory
> locations data like wind speed, temperature, etc. Only the thread that
> updates that table acquires a lock. All others access the data without any
> locks in read mode.
> 
> A program generated with this optimizations reads it once. That's a bug...

A bug in the program that does that.  You can use volatile, or atomics
(including e.g. relaxed __atomic_load, which isn't really expensive).

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]