知识卡片

普通读书笔记卡 · 10294.a.4.a.2.b · 生成模型:未记录

交错执行如何丢更新

理解等级:初级

变量初值为 1,一个线程加 2,另一个乘 2。两个线程若都先读取 1,后写入者会覆盖另一方,得到 2 或 3。按顺序执行时,可得到 4 或 6。一致性模型用可见顺序约束这些历史。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Database Internals》Chapter 8. Introduction and Overview(book-source:extracted/Database Internals A deep-dive into how distributed data systems work (Alex Petrov)/_epub-src/OEBPS/ch08.html#idm46104531213784,段 7) - 结论依据:原文的四种交错展示了分离的读写怎样形成不同结果。 - 原始内容:As soon as two execution threads are allowed to access the variable, the exact outcome of the concurrent step execution is unpredictable, unless the steps are synchronized between the threads. Instead of a single possible outcome, we end up with four, as Figure 8-1 shows.1