WRS.NTO

RISC-V WRS.NTO Instruction Details

Instruction ManualI-type

Wait on reservation set with no timeout

Instruction Syntax

wrs.nto
Operand Breakdown
Destination rd: general-purpose register receiving the result.
Source rs1: register holding the first operand.
Immediate imm: 12-bit signed value, sign-extended before operation with rs1.
ZawrsCache & Sync

Instruction Behavior

Stalls the hart in a low-power state until a store occurs to the reservation set or a pending interrupt is observed. Must be used with LR. Part of Zawrs for energy-efficient polling.

Quick Understanding & Search Notes

WRS.NTO is a Zawrs wait-on-reservation-set instruction used with a prior LR reservation, allowing the hart to temporarily stall while waiting for a store to the reserved location.

A prior LR must establish a reservation set containing the target bytes; the instruction has no address operand.
WRS.NTO has no short timeout, but can end on a store to the reservation set, an observed interrupt, or an implementation choice.
The instructions are available in all privilege modes, but WRS.NTO is affected by the mstatus.TW rule.

Common Usage Scenarios

Cache & Hints

Understand this scenario with real code like «lr.w x10, (x11) ; wrs.nto».

Comparison & Detection

Understand this scenario with real code like «lr.w x10, (x11) ; wrs.nto».

Concurrency & Multi-core

Understand this scenario with real code like «lr.w x10, (x11) ; wrs.nto».

Pre-Use Checklist

Syntax Check
  • Confirm the current instruction format is I-type.
  • Confirm the operand order matches the example.
Semantic Check
  • Ensure the destination register usage is compatible with the calling convention.
  • Confirm this is not the lower-level form of a pseudo-instruction expansion.

Pitfalls / Common Confusions

Must be used with a reservation set established by a prior LR.
mstatus.TW can cause a long wait in lower privilege modes to raise an illegal-instruction exception.
There is no short-timeout guarantee, but the implementation can still end the wait because of a store to the reservation set, an interrupt, or its own choice; software must re-check the condition in a loop.

FAQ

Can WRS.NTO replace LR/SC?

No. It only waits for events related to an existing reservation set; synchronization algorithms still need LR/SC, AMO, or CAS operations to update state.

Will WRS.NTO always sleep until memory changes?

No. The spec allows an implementation to occasionally terminate the stall for any reason, so software must re-check the condition in a loop.