volatile (in comp.lang.c)

T. William Wells bill at proxftl.UUCP
Fri Jun 17 03:55:38 AEST 1988


In article <4922 at ihlpf.ATT.COM>, nevin1 at ihlpf.ATT.COM (00704a-Liber) writes:
> |Fortunately this is sufficient when the programmer understands what he is
> |programming, and chooses data types etc which will ensure atomicity, if that
> |is what he is trying to achieve.
>
> C itself does not guarantee that access to any particular data type,
> including char, is atomic.  My question is:  is there *any* use for 'volatile'
> which does not require 'atomicity' at some level?  If not, then 'volatile'
> doesn't really fix any of the problems we have without it.

The standard solves this problem, almost:

4.7: "The type defined [in header <signal.h>] is sig_atomic_t
which is the integral type of an object that can be accessed as
an atomic entity, even in the presence of asynchronous
interrupts."

Of course, this does not really deal with multiprocessor systems
unless one stretches the definition of asynchronous interrupts to
include asynchronous memory use, a long stretch indeed.



More information about the Comp.lang.c mailing list