blob: dcca37249e9c7ebfaed3adcf69e34eae78ce36d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
Field with multi-threaded access
================================
Problem 1:
type Thing = struct {
threaded byte a
threaded byte b
}
- The CPU instruction(s) that write to a might also touch b.
- Solution: Add padding between a and b, and after b.
Problem 2:
type B = struct {
threaded byte b
}
type Thing = struct {
threaded byte a
threaded struct B b
}
- Same problem as above.
- Padding can be added.
Problem 3:
- Should atomic operations be allowed on threaded items? (Probably yes)
- Which atomic operations to support?
- Do all multi-threading capable CPUs support all atomic operations? (Probably not)
- Do some CPUs require special formatting (such as an extra word) to support atomic operations? (Hopefully not)
|