什么时候同时执行以某种未知顺序产生结果的两个关键部分有用?

When is concurrent execution of two critical sections producing results in some unknown order useful?

参考 Galvin 等人。 al 操作系统概念,第 8 版,第 6 章,第 6.9 节,第 257 页。它说,"If two critical sections are instead executed concurrently, the result is equivalent to their sequential execution in some unknown order. Although this property is useful in many application domains, in many cases we would like to make sure that a critical section forms a single logical unit of work that either is performed in its entirety or is not performed at all." 什么时候 属性 有用?请解释,提前谢谢!还有,请给我一些蔬菜吃!

当关键部分的执行顺序无关紧要时,属性 很有用(因为它增加了潜在的并行性)。

举个更复杂的例子;假设您有一个从文件中获取下一个块的线程,一个压缩当前块的线程,以及一个将先前压缩的块发送到网络连接的线程。

在这种情况下有明显的限制(当前块仍在获取时不能压缩,并且在完成压缩之前不能将压缩块发送到网络连接),但是有在顺序无关的情况下也有明显的并行机会(您不关心下一个块是在当前块被压缩之前还是之后或同时被压缩,您不关心当前块是在压缩之前还是之后或同时被压缩先前压缩的块正在发送到网络,您不关心下一个块是在先前压缩的块发送到网络之前或之后或同时获取的。