book: typo fixes

Fixes #159
This commit is contained in:
Changkun Ou
2020-12-31 09:38:32 +01:00
parent 7eceaf1bee
commit a5445b7c55
2 changed files with 2 additions and 2 deletions

View File

@@ -465,7 +465,7 @@ In order to achieve the ultimate performance and achieve consistency of various
3. Release/Acquire model: Under this model, we can further tighten the order of atomic operations between different threads, specifying the timing between releasing `std::memory_order_release` and getting `std::memory_order_acquire`. **All** write operations before the release operation are visible to any other thread, ie, happens-before.
As you can see, `std::memory_order_release` ensures that the write behavior after it does not occur before the release operation, which is a backward barrier, and`std::memory_order_acquire` ensures that its previous write behavior does not occur after this acquisition operation, there is a forward barrier. For the `std::memory_order_acq_rel` option, it combines the characteristics of the two and uniquely determines a memory barrier, so that the current thread's reading and writing of memory will not be rearranged before and after this operation.
As you can see, `std::memory_order_release` ensures that the write behavior after it does not occur before the release operation, which is a forward barrier, and`std::memory_order_acquire` ensures that its previous write behavior does not occur after this acquisition operation, there is a backward barrier. For the `std::memory_order_acq_rel` option, it combines the characteristics of the two and uniquely determines a memory barrier, so that the current thread's reading and writing of memory will not be rearranged before and after this operation.
Let's check an example:

View File

@@ -474,7 +474,7 @@ int main() {
3. 释放/获取模型:在此模型下,我们可以进一步加紧对不同线程间原子操作的顺序的限制,在释放 `std::memory_order_release` 和获取 `std::memory_order_acquire` 之间规定时序,即发生在释放操作之前的**所有**写操作对其他线程的任何获取操作都是可见的亦即发生顺序happens-before
可以看到,`std::memory_order_release` 确保了它之后的写行为不会发生在释放操作之前,是一个向的屏障,而 `std::memory_order_acquire` 确保了它之前的写行为,不会发生在该获取操作之后,是一个向的屏障。对于选项 `std::memory_order_acq_rel` 而言,则结合了这两者的特点,唯一确定了一个内存屏障,使得当前线程对内存的读写不会被重排到此操作的前后。
可以看到,`std::memory_order_release` 确保了它之后的写行为不会发生在释放操作之前,是一个向的屏障,而 `std::memory_order_acquire` 确保了它之前的写行为,不会发生在该获取操作之后,是一个向的屏障。对于选项 `std::memory_order_acq_rel` 而言,则结合了这两者的特点,唯一确定了一个内存屏障,使得当前线程对内存的读写不会被重排到此操作的前后。
我们来看一个例子: