Implementation of atomic instructions using LR/SC pair

318 views
Skip to first unread message

Sreenadh S

unread,
Jan 31, 2022, 4:56:16 AM1/31/22
to RISC-V SW Dev, li...@cdac.in
In our rv64imafd multi-core  implementation, we had implemented Atomic instructions as a combination of lr and  sc instruction. Is
this implementation complaint to the risc-v specification? Will it make any
issues when running programs compiled for riscv?
Also is there any chance of following type of assembly code generated by the compiler:

lr.d x11, 0(X5)
amoadd.d X2, 0(X6)
sc.d X7, 0(x5)
[In our implementation the above sc.d will always fail]

Charles Papon

unread,
Jan 31, 2022, 6:22:27 AM1/31/22
to RISC-V SW Dev, sreena...@gmail.com, li...@cdac.in
Hi,

From https://github.com/riscv/riscv-isa-manual/blob/23a1255de3af5d5d6a7c6993dc9f44687446c6d4/src/a.tex#L295
Seems that using atomic instruction inside a LR/SC is the issue ^^

Regards
Charles

Bruce Hoult

unread,
Jan 31, 2022, 6:26:02 AM1/31/22
to Sreenadh S, RISC-V SW Dev, li...@cdac.in
9.3 Eventual Success of Store-Conditional Instructions

  • An LR/SC sequence begins with an LR instruction and ends with an SC instruction. The dynamic code executed between the LR and SC instructions can only contain instructions from the base “I” instruction set, excluding loads, stores, backward jumps, taken backward branches, JALR, FENCE, and SYSTEM instructions.  


--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAAurGApwdVC2V4K%2BLzh%3Dh5Uea2S0H86Q04QVTOg3uU5fY5mKkg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages