[Bug 126] Add support for attribute to mark data as volatile.

via D.gnu d.gnu at puremagic.com
Sat May 31 18:40:25 PDT 2014


http://bugzilla.gdcproject.org/show_bug.cgi?id=126

Mike <slavo5150 at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |slavo5150 at yahoo.com

--- Comment #7 from Mike <slavo5150 at yahoo.com> ---
As I understand it, there are 2 issues to be addressed by 'volatile' or some
other solution.

1.  Ensure a memory location is always read/written and not cached in registes
2.  Ensure instructions that access 'volatile' memory are not reordered by the
compiler.

I believe 'shared' satisfies (1), but not (2).  A 'volatile' memory location is
one which the executing thread does not have complete control of, and can
therefore be changed by some other entity external to the executing thread. 
Therefore is it's contents are volatile.  

I think of 'shared' similarly.  The memory location is shared by the executing
thread with other external entities:  other threads, other processors, a
sensor, or other peripheral that may read or write to that memory location
outside of the context of the executing thread.  What 'shared' doesn't satisfy
is (2). 

peek() and poke() intrinsics would satisfy both (1) and (2).   

I see at least 3 solutions:
1.  Add volatile semantics with either a keyword or an attribute requiring
compilers to address both (1) and (2)
2.  Use 'shared' to address requirement (1) and add some other "don't reorder"
feature to the front-end
3.  Add peek() and poke() intrinsics.

I prefer (2), (3), then (1).  I prefer (2) simply because it is more granular
and both 'shared' and a "don't reorder" feature could be used for other
purposes outside of my immediate need which is peripheral memory mapped IO.

-- 
You are receiving this mail because:
You are watching all bug changes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/d.gnu/attachments/20140601/c2fa2d5f/attachment.html>


More information about the D.gnu mailing list