Help educate an old 8-bit assembler mindset
Help educate an old 8-bit assembler mindset
Posted Jun 19, 2021 14:43 UTC (Sat) by corbet (editor, #1)In reply to: Help educate an old 8-bit assembler mindset by felixfix
Parent article: Protecting control dependencies with volatile_if()
It's all a matter of ordering as seen by others. The write to B may be a "I'm dealing with it" flag; some other process may have changed A and wants to be sure that its change will be observed before B is written.
Posted Jun 19, 2021 16:01 UTC (Sat)
by felixfix (subscriber, #242)
[Link] (3 responses)
"That breaks the control dependency, freeing a sufficiently aggressive CPU to move the write ahead of the read, possibly creating a subtle and unpleasant bug."
So again, other than special cases, including aliased variables, I/O, threaded code, and other unenumerated special cases, what kind of subtle and unpleasant bugs can this create? Or does that sentence only refer to special cases?
Posted Jun 19, 2021 17:47 UTC (Sat)
by corbet (editor, #1)
[Link] (2 responses)
Posted Jun 20, 2021 7:29 UTC (Sun)
by pbonzini (subscriber, #60935)
[Link]
Control dependencies also do not matter in most lockless cases, much less control dependencies where the compiler does have meaningful optimizations that would break. Of course, sometimes they do.
Posted Jun 20, 2021 13:58 UTC (Sun)
by felixfix (subscriber, #242)
[Link]
Thanks to all concerned for my education.
Help educate an old 8-bit assembler mindset
This is an article about kernel programming, where everything is threaded. Or, as the article says, "The effects of this reordering on single-threaded code are (in the absence of bugs) limited to making it run faster. When there are multiple threads of execution running simultaneously, though, there can be surprises in store. One thread may observe things happening in a different order than others, leading to all sorts of unfortunate confusion."
Help educate an old 8-bit assembler mindset
Help educate an old 8-bit assembler mindset
Help educate an old 8-bit assembler mindset