From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <676c3c4f0512090859n72ec5bd1rfa7742b43faf526b@mail.gmail.com> Date: Fri, 9 Dec 2005 11:59:01 -0500 From: Richard Bilson To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] const In-Reply-To: <3e1162e60512090825n4d944cc8yb2f668e3deb64dec@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_6542_7317183.1134147541222" References: <3e1162e60512090825n4d944cc8yb2f668e3deb64dec@mail.gmail.com> Topicbox-Message-UUID: bffcf222-ead0-11e9-9d60-3106f5b1d025 ------=_Part_6542_7317183.1134147541222 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 12/9/05, David Leimbach wrote: > > Volatile is useful for telling compilers not to stick data in registers, > which is helpful for multi-threaded situations with shared memory ... > sometimes :) > > If I were to write a semaphore or another synchronization method using > shared memory on unix I'd probably type volatile and then pray :). > > It often feels more of a faith issue than a knowledge issue though :) > It is a matter of faith, and usually misplaced at that, since volatile isn'= t usually defined to place any constraints on the order in which operations become visible to other processors. Certainly not in the C, C++, or POSIX standards, although some platform ABIs do specify this to some degree. Both POSIX and C++ are trying to deal with this, but it's an uphill battle since processors differ widely on the sorts of constraints that they can support efficiently. In the meantime, people sprinkle volatile around and pray. All the world's an x86, right? ------=_Part_6542_7317183.1134147541222 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 12/9/05, David Leimbach <leimy2k@gmail.com> wrote:
Volatile is useful for telling compilers not to stick  data in registers, which is helpful for multi-threaded situations with shared memory ... sometimes :)

If I were to write a semaphore or another synchronization method using shared memory on unix I'd probably type volatile and then pray :).

It often feels more of a faith issue than a knowledge issue though = :)

It is a matter of faith, and usually misplaced at that, since volatile isn't usually defined to place any constraints on the order in which operations become visible to other processors. Certainly not in the C, C++, or POSIX standards, although some platform ABIs do specify this to some degree.

Both POSIX and C++ are trying to deal with this, but it's an uphill battle since processors differ widely on the sorts of constraints that they can support efficiently.

In the meantime, people sprinkle volatile around and pray. All the world's = an x86, right?
------=_Part_6542_7317183.1134147541222--