Skip to content

Commit

Permalink
fix post: cpp concurrency programming note (#3)
Browse files Browse the repository at this point in the history
* Update 2023-12-25-cpp-concurrency.md

* add author
  • Loading branch information
Serein207 committed Dec 26, 2023
1 parent e92a8c0 commit 25022c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 7 additions & 1 deletion blog/.authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ authors:
avatar: https://aliyun.sastimg.mxte.cc/images/2023/12/17/QQ20220819164336a533d1c9c523e00b.th.jpg
slug: url # Author profile slug
url: https://wiki.sast.fun # Author website URL
Serein:
name: Serein
description: SASTer
avatar: https://avatars.githubusercontent.com/u/118594118
slug: url # Author profile slug
url: https://wiki.sast.fun # Author website URL
NONE:
name: 匿名
description: SASTer
avatar: https://aliyun.sastimg.mxte.cc/images/2023/12/17/QQ20220819164336a533d1c9c523e00b.th.jpg
slug: url # Author profile slug
url: https://wiki.sast.fun # Author website URL
url: https://wiki.sast.fun # Author website URL
10 changes: 5 additions & 5 deletions blog/posts/2023-12-25-cpp-concurrency.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ categories:
tags:
- C++
authors:
squidfunk:
name: Serein
description: SASTer
avatar: https://avatars.githubusercontent.com/u/118594118
- Serein
---

聊聊C++并发编程中比较高级的无锁编程。

## 内存模型基础

### 对象和内存位置
Expand All @@ -20,6 +19,7 @@ authors:
2. 每个对象至少占有一个内存位置。
3. 基本类型都有确定的内存位置(无论类型大小如何,即使他们是相邻的,或是数组的一部分)。
4. 相邻位域是相同内存中的一部分。
<!--more-->

### 对象、内存位置和并发

Expand Down Expand Up @@ -509,4 +509,4 @@ void func(int *data) {

由于`读寄存器地址1``写flag,标记中断处理完成`这两者之间的关系是读写关系。并不能被`std::memory_order_release`约束。所以需要更强的约束来处理。

这里可以使用`std::memory_order_acq_rel`,即对本条语句的读写进行约束。即表示写不后,读不前同时生效。 那么就可以保证`a, b, c`三个操作不会乱序。即`std::memory_order_acq_rel`可以同时表示 **写不后 && 读不前**
这里可以使用`std::memory_order_acq_rel`,即对本条语句的读写进行约束。即表示写不后,读不前同时生效。 那么就可以保证`a, b, c`三个操作不会乱序。即`std::memory_order_acq_rel`可以同时表示 **写不后 && 读不前**

0 comments on commit 25022c4

Please sign in to comment.