Skip to content

Commit

Permalink
Move non-normative parts of "A" extensions (atomics) into NOTE block (#…
Browse files Browse the repository at this point in the history
…1822)

* a-st-ext: mark examples as a note

Examples are usually in note blocks already.  Make these consistent.

The text about compare-and-swap example should probably be improved and
moved above the example.

Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com>

* a-st-ext: remove manual page breaks

We should improve the tooling instead of adding manual page breaks.

Also replace "above" with a reference, because "above" is not correct
anymore and most importantly, it's not acceptable for a spec.

This does not imply any acceptability of the the rest of the sentence,
I just didn't want to leave the spec in a worse shape.

Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com>

---------

Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com>
  • Loading branch information
radimkrcmar authored Jan 25, 2025
1 parent d7ae73a commit 91b80d3
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/a-st-ext.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ instruction unless the _rl_ bit is also set. LR._rl_ and SC._aq_
instructions are not guaranteed to provide any stronger ordering than
those with both bits clear, but may result in lower performance.

<<<

[NOTE]
====
[[cas]]
[source,asm]
.Sample code for compare-and-swap function using LR/SC.
Expand All @@ -250,6 +250,7 @@ those with both bits clear, but may result in lower performance.
LR/SC can be used to construct lock-free data structures. An example
using LR/SC to implement a compare-and-swap function is shown in
<<cas>>. If inlined, compare-and-swap functionality need only take four instructions.
====

[[sec:lrscseq]]
=== Eventual Success of Store-Conditional Instructions
Expand Down Expand Up @@ -434,15 +435,15 @@ both imply additional unnecessary ordering as compared to AMOs with the
corresponding _aq_ or _rl_ bit set.
====

[NOTE]
====
An example code sequence for a critical section guarded by a
test-and-test-and-set spinlock is shown in
Example <<critical>>. Note the first AMO is marked _aq_ to
order the lock acquisition before the critical section, and the second
AMO is marked _rl_ to order the critical section before the lock
relinquishment.
<<<

[[critical]]
[source,asm]
.Sample code for mutual exclusion. `a0` contains the address of the lock.
Expand All @@ -457,9 +458,7 @@ relinquishment.
# ...
amoswap.w.rl x0, x0, (a0) # Release lock by storing 0.
[NOTE]
====
We recommend the use of the AMO Swap idiom shown above for both lock
We recommend the use of the AMO Swap idiom shown in <<critical>> for both lock
acquire and release to simplify the implementation of speculative lock
elision. cite:[Rajwar:2001:SLE]
====
Expand Down

0 comments on commit 91b80d3

Please # to comment.