Kernel quote of the week
Look, memory ordering pretty much _is_ the rocket science of CS, but the C standards committee basically made it a ton harder by specifying "we have to make the rocket out of duct tape and bricks, and only use liquid hydrogen as a propellant".— Linus Torvalds (Thanks to Mathieu Desnoyers.)
Posted Jun 10, 2021 21:40 UTC (Thu)
by prauld (subscriber, #39414)
[Link]
Posted Jun 11, 2021 0:22 UTC (Fri)
by ncm (guest, #165)
[Link] (2 responses)
It was not long ago that Gcc obeyed the Standard requirements on volatile by issuing a load instruction immediately after each assignment to a volatile lvalue, because the assignment operation yields an rvalue that (they interpreted) requires an explicit load even if the result is immediately discarded. Writers of drivers for devices that would not tolerate an extra register read had to use an asm block. I don't doubt that Linus objected to that behavior, but I do doubt that the Standard was changed; rather, Gcc simply fell into line ignoring the requirement, like other compilers. Volatile has always had its own difficulties, and very rarely means what most using it hope.
I knew a core FreeBSD maintainer who insisted (and might still, if you asked) that a volatile flag was entirely sufficient to coordinate between threads on different cores, and firmly convinced our mutual employer. Good times.
Posted Jun 11, 2021 4:55 UTC (Fri)
by vtjnash (subscriber, #141755)
[Link] (1 responses)
I feel like I have clearly spent too much time attempting to learn about memory model details. And now on top of it, need to see if I can grok volatile_if someday.
Posted Jun 11, 2021 7:43 UTC (Fri)
by ncm (guest, #165)
[Link]
Kernel quote of the week
Kernel quote of the week
Kernel quote of the week
Kernel quote of the week
