Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd31da4c

Browse files
committed
book: fix typo in memory order acquire
Fixeschangkun#96
1 parenta5d1563 commitd31da4c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

‎book/en-us/07-thread.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ In order to achieve the ultimate performance and achieve consistency of various
462462
463463
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.
464464
465-
As you can see, `std::memory_order_release` ensures that the write behavior after it does not occur before the release operation, is a backward barrier, and`std::memory_order_acquire` ensurestheprevious write behaviorafter it, no It will happenafterthe get operation,it is a forward barrier. For theoption`std::memory_order_acq_rel`, it combines the characteristics of the two, andonly determines a memory barrier, so that the current thread reads andwrites to thememory. Will not be rearranged before and after this operation.
465+
As you can see, `std::memory_order_release` ensures that the write behavior after it does not occur before the release operation,whichis a backward barrier, and`std::memory_order_acquire` ensuresthat itsprevious write behaviordoes not occurafterthis acquisition operation,there is a forward barrier. For the `std::memory_order_acq_rel` option, it combines the characteristics of the two anduniquely determines a memory barrier, so that the current thread's reading andwriting ofmemory will not be rearranged before and after this operation.
466466
467467
Let's check an example:
468468

‎book/zh-cn/07-thread.md

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp