知识卡片
数据竞争取决于冲突与同步
不同线程访问同一内存位置,至少一方写入且缺少正确同步时,会构成数据竞争。它不是一切并发错误的统称:每次访问都加锁,仍可能因检查与更新分离而有业务竞态。先区分访问安全和跨步骤不变量,才能选对同步范围。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 3. Concepts Data Races · 查看原书依据
Data Races Let’s start with the good news, by exploring data races and Rust. The precise technical definition of a data race varies from language to language, but we can summarize the key components as follows: A data race is defined to occur when two distinct threads access the same memory location, under the following conditions: At least one of them is a
参考来源
- 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第3章《Data Races》(spine7;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch03.html;u100-ch03-031)。
- 结论依据:原文在“Data Races”附近的定义、例子或代码支撑本卡核心说明:不同线程访问同一内存位置,至少一方写入且缺少正确同步时,会构成数据竞争。边界按已读前提解释;示例未执行。
- 原始内容:Data Races Let’s start with the good news, by exploring data races and Rust. The precise technical definition of a data race varies from language to language, but we can summarize the key components as follows: A data race is defined to occur when two distinct threads access the same memory location, under the following conditions: At least one of them is a