WRS.NTO

RISC-V WRS.NTO Instruction Details

Instruction ManualI-type

Wait on reservation set with no timeout

Instruction Syntax

wrs.nto
Operand Breakdown
WRS.NTO has no explicit assembly operands; it uses a fixed SYSTEM I-type encoding.
funct12 is fixed to 000000001101, with rs1=x0, funct3=000, rd=x0, and opcode=1110011.
Reservation-set validity, pending interrupts, and the implementation-defined stall duration are implicit architectural or implementation state, not assembly register or immediate operands.
ZawrsCache & Sync

Instruction Encoding

31..20
funct12
19..15
rs1=x0
14..12
funct3
11..7
rd=x0
6..0
opcode

WRS-NTO uses opcode 1110011 (0x73), funct3 000, funct12 000000001101, rs2 fixed x0. This fixed SYSTEM encoding has no explicit assembly register or immediate operand; funct12, rs1, funct3, rd, and opcode must match the constants listed in the manual.

Format: SYSTEM I-type fields
opcode: 1110011 (0x73)
funct3: 000 (0x0)
funct12: 000000001101 (0x00d)
rs2: fixed x0

Instruction Behavior

May temporarily stall a hart while its LR-established reservation set is valid and no pending interrupt is observed, even if disabled. An implementation may occasionally end the stall for any reason.

Quick Understanding & Search Notes

WRS.NTO is a Zawrs wait-on-reservation-set instruction: a hart can temporarily stall while its reservation set is valid and no pending interrupt is observed; LR establishes that reservation set.

To wait for target bytes to be written, LR should first establish a reservation set containing them; 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. WRS.NTO has a bounded-time illegal-instruction rule outside M mode with mstatus.TW=1; in VS/VU modes, mstatus.TW=0 plus hstatus.VTW=1 instead gives a virtual-instruction exception.

Common Usage Scenarios

Cache & Hints

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

Comparison & Detection

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

Concurrency & Multi-core

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

Pre-Use Checklist

Syntax Check
  • Verify the immediate field is within the valid range.
  • Confirm source register rs1 points to the correct operand.
Semantic Check
  • Check if the immediate sign-extension matches expectations.
  • Ensure the result register rd has a clear purpose.

Pitfalls / Common Confusions

To wait for a memory location to be written, first use LR to establish a reservation set that includes its bytes.
With mstatus.TW=1, WRS.NTO outside M mode raises an illegal-instruction exception if it does not complete within an implementation-specific bounded time. In VS/VU modes, with mstatus.TW=0 and hstatus.VTW=1, the same noncompletion causes a virtual-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 waits on a reservation set; LR/SC, AMO, or CAS updates shared state.

Will WRS.NTO always sleep until memory changes?

No. An implementation may end the stall for any reason; software must re-check the condition.