Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 33,164 of 33,346    |
|    Francis Glassborow to All    |
|    Re: Array thread safety in C++11    |
|    11 Aug 13 00:09:38    |
      From: francis.glassborow@btinternet.com              On 10/08/2013 13:05, fmatthew5876 wrote:       >> On Itanium, g++ <= 4.7 was even reputed to do that with adjacent       >> members of a struct which happened to fall within the same 64 bit       >> alignment.              >       > Essentially the only type that is unsafe to read and write is a bitfield.       > If a processor is ever designed that cannot do single byte reads and       > writes then chars will have to be padded and aligned so that the processor       can       > write to them without interfering with other memory locations.              That looks wrong to me. AFAIK there are quite a few processors that       cannot read/write octets without loading a larger memory location.              C++ implementers then have to choose between having a char that is       larger than an octet (quite a common choice on some kinds of hardware)       and packing several 8-bit char into a single address (by using address       and offset). In theory they could use just part of the memory at an       address (and on reflection, I think that has been done in the past for       some fundamental types)              >       > What that would mean for doing binary IO is anyone's guess.       >       > For compilers it is now illegal to do optimizations like single       > byte reads and writes using 32/64 bit loads and stores unless       > the compiler can prove that only one thread can access the variable.       > (stack variables maybe?)              Assuming you are correct (I am a bit doubtful) then what does an       implementation do on a machine with 32-bit or 64-bit storage? It seems       to me that you are saying that we cannot implement C++ on such a machine.              I think that the implementation has to ensure that if the memory at a       single address contains more than one char (for example) that multiple       threads cannot simultaneously attempt to write to distinct parts of that       memory. Of course the simplest way to achieve that is to always have a       char occupy the whole of the storage at an address (i.e. no use of       address and offset). However that could be problematic if you want to       use octets.                     Francis                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca