volatile: a summary

Every system needs one terry at wsccs.UUCP
Tue Jun 14 12:10:36 AEST 1988


In article <3811 at pasteur.Berkeley.Edu>, faustus at ic.Berkeley.EDU (Wayne A. Christopher) writes:
> In article <11837 at mimsy.UUCP>, chris at mimsy.UUCP (Chris Torek) writes:
> > 	Is the [volatile] keyword necessary?
> > 
> > A perfect compiler would know as much as all its programmers combined,
> > and could use whatever rules those programmers would use to detect
> > `real volatility'.

Yes yes yes.

> The problem is that these rules may be in the manual for the graphics
> board the programmer is writing a driver for.  Say there are two memory
> mapped registers, "model_number" and "time_of_day", declared as
> 
> int *model_number = (int *) 0xf0;	/* Shouldn't be volatile. */
> int *time_of_day  = (int *) 0ff4;	/* Should be volatile. */
> 
> model_number will never change, but time_of_day will.  How is the compiler
> going to tell the difference, without volatile?

No no no.

The compiler will know because, as part of the board installation, you will
tell it... or we could make a hardware-standard (I know; too much to ask for)
method of asking it.  The machine should "know" about the machine.  How can
you possibly expect it to know if you don't tell it ("how can you have any
pudding if you don't eat your meat?").  The question raised by your new board
is whether "volitility" will be defined in an installation dependant way by
the programmer, or in an installation independant way by the installer.  We
have a great deal of hardware-specific kernel information already there...
what's the point in providing yet another method of making "magic" numbers
"known" to the computer via "volitile" in the compiler when it is just as
easily done by reference to a device configuration file?  This file would
not only be useful to the compiler, it would allow configuration, and possibly
even machine independant installation of drivers and devices.


| Terry Lambert           UUCP: ...{ decvax, ihnp4 } ...utah-cs!century!terry |
| @ Century Software        OR: ...utah-cs!uplherc!sp7040!obie!wsccs!terry    |
| SLC, Utah                                                                   |
|                   These opinions are not my companies, but if you find them |
|                   useful, send a $20.00 donation to Brisbane Australia...   |
| 'Signatures; it's not how long you make them, it's how you make them long!' |



More information about the Comp.lang.c mailing list