Path: csiph.com!1.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!border2.nntp.ams1.giganews.com!nntp.giganews.com!buffer2.nntp.ams1.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Sat, 27 Aug 2016 00:34:19 -0500 From: Gareth Owen Newsgroups: comp.lang.c Subject: Re: Default values in #define References: <1Kgvz.279$6d.174@fx26.iad> <8277ffd2-121d-4f3a-9bb0-ad3068696415@googlegroups.com> <502669cd-f0fc-4b99-8c8a-0d806c8b5f20@googlegroups.com> <11e2bb75-ee3c-4904-b7c8-77023426fb45@googlegroups.com> <87vaynj0l9.fsf@bsb.me.uk> <4c14769d-f75d-4c8f-89f6-5290f6b97b32@googlegroups.com> <87poovitqy.fsf@bsb.me.uk> <62672946-dc1f-4d94-9c33-5434f51da85d@googlegroups.com> <71637eed-ce54-4950-9568-d053ff0abc84@googlegroups.com> <91a99d84-b481-4dae-949b-914cb5e8aab7@googlegroups.com> Date: Sat, 27 Aug 2016 06:34:19 +0100 Message-ID: <87inum4vxg.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:cJ3zqFwUE8Mo8qnkiZSmhzNI7fw= MIME-Version: 1.0 Content-Type: text/plain Lines: 36 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-Zw89mSi4PMBlhQpDTyMKre0SWIW/0JMh0sRYfRQauLNRwB47OV/Lde0Uulx4UZrBq0hIdQr7VztUBaL!qJ6rfX3noklToP2ENKn7ZkyGW0/W1Kp9EcqTt00PXZJR8S1rIM5/l4KnVcydVThTRxdD6w== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3472 Xref: csiph.com comp.lang.c:92789 Malcolm McLean writes: > On Saturday, August 27, 2016 at 2:47:12 AM UTC+1, Ian Collins wrote: >> >> Volatile is essentially useless for what it isn't intended to do! It >> does its intended job perfectly well. >> > volatile means that the object is subject to change at any time > by an outside force. But that only makes sense if it is coherent. > > We can obviously change the price of beer. Due to the wicked and > excessive taxes exacted by government, it might have to go up > 10p. So if I understand your analogy, you mean beer price is volatile. > So it goes from 3.20 to 3.30. But there isn't an intermediate second > between the barman rubbing out the 2 and writing the 3 when you can > get a beer for 3.0. So beer pricing is non-atomic (the barman rubs out one digit at a time), but it appears to be atomic because the barman acts as a many-reader-one-writer mutex. The price update is slow, but the barman prevents readers (drinkers) from accessing the new price (buying cheap beer) until the update is complete. > That's nonsense. Maybe, but that's the rules. Consider a large DMA buffer that is used by a camera chip to store image data. Individual byte updates are atomic, but t he entire buffer is volatile (the camera changes the data behind the programs back), but if you take a snapshot of that buffer without some sort of sync mechanism (an end-of-frame interrupt, say) you'll get a inconsistent result (i.e. tearing between a new frame and the previous)