March 28, 2002 Re: Volatile | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stephen Fuld | "Stephen Fuld" <s.fuld.pleaseremove@att.net> wrote in message news:a7tm71$2sjd$2@digitaldaemon.com... > > "OddesE" <OddesE_XYZ@hotmail.com> wrote in message news:a7tf5d$2p0k$1@digitaldaemon.com... > > > > "Stephen Fuld" <s.fuld.pleaseremove@att.net> wrote in message > > news:a7t4ca$2jfd$2@digitaldaemon.com... > > <SNIP> > > > The lock mechanism is a separate issue, but I do believe there should be > a > > > defined access to the low cost locks offerred by atomic instructions in > > most > > > architectures. > > > > > > -- > > > - Stephen Fuld > > > e-mail address disguised to prevent spam > > > > > > > Isn't depending on atomic instructions dangerous? > > What about multi-processor systems, where two > > atomic instructions might execute simultaneously? > > The atomic instructions I was talking about are things like test and set, compare and swap, or atomic fetch-op-store, where the memory is locked for the duration of the instruction. These are safe in multi-processor systems. > Sorry if I confused you. > > -- > - Stephen Fuld > e-mail address disguised to prevent spam > You didn't confuse me, the topic just does. Multi threading issues are one of my weaker points when it comes to programming... :( Thanks for clearing it up. -- Stijn OddesE_XYZ@hotmail.com http://OddesE.cjb.net _________________________________________________ Remove _XYZ from my address when replying by mail |
March 31, 2002 Re: Volatile | ||||
---|---|---|---|---|
| ||||
Posted in reply to Richard Krehbiel Attachments:
| That's a great link! Thanks. Interestingly, Linus appears to have come to the same conclusion about volatile I did: "But the fact is, that when you add "volatile" to the register, it really tells gcc "Be afraid. Be very afraid. This user expects some random behaviour that is not actually covered by any standard, so just don't ever use this variable for any optimizations, even if they are obviously correct. That way he can't complain". -Linus "Richard Krehbiel" <rich@kastle.com> wrote in message news:a7secs$27fl$1@digitaldaemon.com... (Apology: This message is HTML so a massive link might still be clickable.) Go read a Linux Torvalds rant about SMP-safety, volatile, and "barrier()" (which is the Linux kernel's equivalent of "sequence"). And much of the thread is interesting, so I'm linking the whole thing (with this massive link - sorry). http://groups.google.com/groups?hl=en&threadm=linux.kernel.Pine.LNX.4.33.0107231546430.7916-100000%40penguin.transmeta.com&rnum=5&prev=/groups%3Fq%3Dtorvalds%2Btransmeta%2Bbarrier%26hl%3Den Boiled down, Torvalds believes that "volatile" as a storage class modifier is always wrong; if "volatile" semantics (whatever they are) are needed, then apply them at the moment of access (as with a cast). |
Copyright © 1999-2021 by the D Language Foundation