GCC interpretation of C11 atomics (DR 459)
Ruslan Nikolaev via gcc
gcc@gcc.gnu.org
Tue Feb 27 17:33:00 GMT 2018
> Consider a producer-consumer relationship between two processes where
> the producer doesn't want to wait for the consumer. For example, the
> producer could be an application that's being traced, and the consumer
> is a trace aggregation tool. The producer can provide a read-only
> mapping to the consumer, and put a nonblocking ring buffer or something
> similar in there. That allows the consumer to read, but it still needs
> atomic access because the consumer is modifying the ring buffer
> concurrently.
Sorry for getting into someone's else conversation... And what good solution gcc offers right now? It forces producer and consumer to use lock-based (BTW: global lock!) approach for *both* producer and consumer if we are talking about 128-bit types. Therefore, sometimes producers *will* wait (by, effectively, blocking). Basically, it becomes useless. In this case, I would rather use a lock-based approach which at least does not use a global lock. On the contrary, the alternative implementation would have been at least useful when both producers and consumers have full (RW) access.
Anyway, I already said that I personally will go with assembly inlines for right now. I just wanted to raise this concern since other people may find it useful in their projects.
More information about the Gcc
mailing list