知识卡片

普通读书笔记卡 · 6074.e.1.b.3

数据竞争取决于冲突与同步

理解等级:中级

不同线程访问同一内存位置,至少一方写入且缺少正确同步时,会构成数据竞争。它不是一切并发错误的统称:每次访问都加锁,仍可能因检查与更新分离而有业务竞态。先区分访问安全和跨步骤不变量,才能选对同步范围。

这张卡片看不懂?

已有反馈 · 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