tmp/tmpki3h1060/{from.md → to.md}
RENAMED
|
@@ -1,16 +1,16 @@
|
|
| 1 |
-
##
|
| 2 |
|
| 3 |
The fundamental storage unit in the C++ memory model is the *byte*. A
|
| 4 |
byte is at least large enough to contain any member of the basic
|
| 5 |
-
execution character set
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
|
| 13 |
[*Note 1*: The representation of types is described in
|
| 14 |
[[basic.types]]. — *end note*]
|
| 15 |
|
| 16 |
A *memory location* is either an object of scalar type or a maximal
|
|
@@ -19,11 +19,11 @@ sequence of adjacent bit-fields all having nonzero width.
|
|
| 19 |
[*Note 2*: Various features of the language, such as references and
|
| 20 |
virtual functions, might involve additional memory locations that are
|
| 21 |
not accessible to programs but are managed by the
|
| 22 |
implementation. — *end note*]
|
| 23 |
|
| 24 |
-
Two or more threads of execution
|
| 25 |
separate memory locations without interfering with each other.
|
| 26 |
|
| 27 |
[*Note 3*: Thus a bit-field and an adjacent non-bit-field are in
|
| 28 |
separate memory locations, and therefore can be concurrently updated by
|
| 29 |
two threads of execution without interference. The same applies to two
|
|
@@ -34,11 +34,11 @@ is not safe to concurrently update two bit-fields in the same struct if
|
|
| 34 |
all fields between them are also bit-fields of nonzero
|
| 35 |
width. — *end note*]
|
| 36 |
|
| 37 |
[*Example 1*:
|
| 38 |
|
| 39 |
-
A
|
| 40 |
|
| 41 |
``` cpp
|
| 42 |
struct {
|
| 43 |
char a;
|
| 44 |
int b:5,
|
|
@@ -47,11 +47,11 @@ struct {
|
|
| 47 |
d:8;
|
| 48 |
struct {int ee:8;} e;
|
| 49 |
}
|
| 50 |
```
|
| 51 |
|
| 52 |
-
contains four separate memory locations: The
|
| 53 |
`d` and `e.ee` are each separate memory locations, and can be modified
|
| 54 |
concurrently without interfering with each other. The bit-fields `b` and
|
| 55 |
`c` together constitute the fourth memory location. The bit-fields `b`
|
| 56 |
and `c` cannot be concurrently modified, but `b` and `a`, for example,
|
| 57 |
can be.
|
|
|
|
| 1 |
+
### Memory model <a id="intro.memory">[[intro.memory]]</a>
|
| 2 |
|
| 3 |
The fundamental storage unit in the C++ memory model is the *byte*. A
|
| 4 |
byte is at least large enough to contain any member of the basic
|
| 5 |
+
execution character set [[lex.charset]] and the eight-bit code units of
|
| 6 |
+
the Unicode UTF-8 encoding form and is composed of a contiguous sequence
|
| 7 |
+
of bits,[^9] the number of which is *implementation-defined*. The least
|
| 8 |
+
significant bit is called the *low-order bit*; the most significant bit
|
| 9 |
+
is called the *high-order bit*. The memory available to a C++ program
|
| 10 |
+
consists of one or more sequences of contiguous bytes. Every byte has a
|
| 11 |
+
unique address.
|
| 12 |
|
| 13 |
[*Note 1*: The representation of types is described in
|
| 14 |
[[basic.types]]. — *end note*]
|
| 15 |
|
| 16 |
A *memory location* is either an object of scalar type or a maximal
|
|
|
|
| 19 |
[*Note 2*: Various features of the language, such as references and
|
| 20 |
virtual functions, might involve additional memory locations that are
|
| 21 |
not accessible to programs but are managed by the
|
| 22 |
implementation. — *end note*]
|
| 23 |
|
| 24 |
+
Two or more threads of execution [[intro.multithread]] can access
|
| 25 |
separate memory locations without interfering with each other.
|
| 26 |
|
| 27 |
[*Note 3*: Thus a bit-field and an adjacent non-bit-field are in
|
| 28 |
separate memory locations, and therefore can be concurrently updated by
|
| 29 |
two threads of execution without interference. The same applies to two
|
|
|
|
| 34 |
all fields between them are also bit-fields of nonzero
|
| 35 |
width. — *end note*]
|
| 36 |
|
| 37 |
[*Example 1*:
|
| 38 |
|
| 39 |
+
A class declared as
|
| 40 |
|
| 41 |
``` cpp
|
| 42 |
struct {
|
| 43 |
char a;
|
| 44 |
int b:5,
|
|
|
|
| 47 |
d:8;
|
| 48 |
struct {int ee:8;} e;
|
| 49 |
}
|
| 50 |
```
|
| 51 |
|
| 52 |
+
contains four separate memory locations: The member `a` and bit-fields
|
| 53 |
`d` and `e.ee` are each separate memory locations, and can be modified
|
| 54 |
concurrently without interfering with each other. The bit-fields `b` and
|
| 55 |
`c` together constitute the fourth memory location. The bit-fields `b`
|
| 56 |
and `c` cannot be concurrently modified, but `b` and `a`, for example,
|
| 57 |
can be.
|