Path: utzoo!mnetor!uunet!husc6!bloom-beacon!mit-eddie!rutgers!bellcore!tness7!petro!swrinde!ut-sally!utah-cs!utah-gr!uplherc!sp7040!obie!wes From: wes@obie.UUCP (Barnacle Wes) Newsgroups: comp.lang.c Subject: Re: volatile isn't necessary, but it's there Message-ID: <144@obie.UUCP> Date: 10 Apr 88 19:08:28 GMT References: <7794@alice.UUCP> <48767@sun.uucp> Organization: the Well of Souls Lines: 25 Summary: ++ not atomic? Says who? In article <48767@sun.uucp>, guy@gorodish.Sun.COM (Guy Harris) writes: | It is worth noting, for example, that there is no guarantee that "++mutex" | is an atomic operation. It is, in fact, worth noting that even if "extern | volatile char mutex;" was used, there would be no guarantee that "++mutex" | is atomic. In all cases, for example, "++mutex" takes an instruction to | load "mutex" into a register, an instruction to increment it, and an | instruction to store it, on a SPARC. The same would be true of any other | architecture lacking an instruction performing an "add 1 to memory" | operation. Another good reason NOT to use a SPARC for anything other than a paperweight. On a reasonable processor like the M68000, `++mutex' becomes an atomic operation like `addq #1,mutex'. | This is a real problem; there were some mildly entertaining bugs on Sun-4 | caused by statements such as "++mutex;" in the kernel not being surrounded by | "spl" calls. Did you get these bugs squashed, or will you relase the Sun-4 SunOS with them intact? -- /\ - "Against Stupidity, - {backbones}! /\/\ . /\ - The Gods Themselves - utah-cs!utah-gr! / \/ \/\/ \ - Contend in Vain." - uplherc!sp7040! / U i n T e c h \ - Schiller - obie!wes