知识卡片
sync在消费子结果前建立汇合
父过程在使用spawn子过程返回值前须执行sync,等待此前派生的子过程结束;
否则可能读取尚未赋值的结果。过程返回前也可隐含一次sync。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 第26章 并行算法 · 查看原书依据
The keyword sync indicates that the procedure must wait as necessary for all its spawned children to finish before proceeding to the statement after the sync—the “join” of a fork-join parallel computation. The P-FIB
参考来源
- 位置:《算法导论(第4版)》第26章《并行算法》(OEBPS/chapter026.xhtml,文本字符[10000,15000))。
- 结论依据:26.1节说明sync等待所有已派生子过程及其必要性。
- 原始内容:The keyword sync indicates that the procedure must wait as necessary for all its spawned children to finish before proceeding to the statement after the sync —the “join” of a fork-join parallel computation. The P-F IB