IssueRaiser

There seems to be an implicit assumption in this code that writes which one thread makes will be seen by other threads in the same order.

There seems to be an implicit assumption in this code that writes which one thread makes will be seen by other threads in the same order. This is not the case on modern architectures. You need both compiler and machine-level memory barriers to ensure this. C's "volatile" keyword does not provide either. The Linux kernel guys wrote an in-depth explanation of why volatile doesn't work for this use-case here: https://www.kernel.org/doc/Documentation/volatile-considered...

Posted by colin_mccabe on May 5, 2014, 12:30 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.9,500 issues0 comments

hackernews (E-commerce)

There seems to be an implicit assumption in this code that writes which one thread makes will be seen by other threads in the same order.

colin_mccabeMay 5, 2014, 12:30 AM

There seems to be an implicit assumption in this code that writes which one thread makes will be seen by other threads in the same order. This is not the case on modern architectures. You need both compiler and machine-level memory barriers to ensure this. C's "volatile" keyword does not provide either. The Linux kernel guys wrote an in-depth explanation of why volatile doesn't work for this use-case here: https://www.kernel.org/doc/Documentation/volatile-considered...

Comments (0)

No comments yet. Start the discussion.

Comment on this issue