Skip to content

Commit 3512b31

Browse files
authored
Merge pull request cch123#22 from wziww/master
新增用户态 false sharing 例子
2 parents 6e9b579 + 5456cfa commit 3512b31

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

memory_barrier.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,20 @@ var semtable [semTabSize]struct {
460460

461461
用户态的代码对 false sharing 其实关注的比较少。
462462

463+
例:
464+
sync/pool.go
465+
466+
```go
467+
type poolLocal struct {
468+
poolLocalInternal
469+
470+
// Prevents false sharing on widespread platforms with
471+
// 128 mod (cache line size) = 0 .
472+
pad [128 - unsafe.Sizeof(poolLocalInternal{})%128]byte
473+
}
474+
```
475+
476+
463477
## runtime 中的 publicationBarrier
464478

465479
TODO

0 commit comments

Comments
 (0)