[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4643947C.10105@tmr.com>
Date: Thu, 10 May 2007 17:54:04 -0400
From: Bill Davidsen <davidsen@....com>
To: Jonathan Corbet <corbet@....net>
CC: linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
Randy Dunlap <randy.dunlap@...cle.com>
Subject: Re: [PATCH] "volatile considered harmful" document
Jonathan Corbet wrote:
> +There are still a few rare situations where volatile makes sense in the
> +kernel:
> +
> + - The above-mentioned accessor functions might use volatile on
> + architectures where direct I/O memory access does work. Essentially,
> + each accessor call becomes a little critical section on its own and
> + ensures that the access happens as expected by the programmer.
> +
> + - Inline assembly code which changes memory, but which has no other
> + visible side effects, risks being deleted by GCC. Adding the volatile
> + keyword to asm statements will prevent this removal.
> +
> + - The jiffies variable is special in that it can have a different value
> + every time it is referenced, but it can be read without any special
> + locking. So jiffies can be volatile, but the addition of other
> + variables of this type is frowned upon. Jiffies is considered to be a
> + "stupid legacy" issue in this regard.
It would seem that any variable which is (a) subject to change by other
threads or hardware, and (b) the value of which is going to be used
without writing the variable, would be a valid use for volatile.
--
Bill Davidsen <davidsen@....com>
"We have more to fear from the bungling of the incompetent than from
the machinations of the wicked." - from Slashdot
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists