wrs.sto
Wait-on-Reservation-Set-with-Short-Timeout
- Extension
- Zawrs
- XLEN
- RV32 and RV64
- Assembly (riscv-unified-db)
wrs.sto- Length
- 32-bit
Encoding
| 3120 | 197 | 62 | 10 | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 000000011101 | 0000000000000 | 11100 | 11 | ||||||||||||||||||||||||||||
Match 0x01d00073, mask 0xffffffff. Source: wrs.sto 31..20=0x01D 19..7=0 6..2=0x1C 1..0=3 in riscv-opcodes/extensions/rv_zawrs.
Description
Instead of polling for a store to a specific memory location, software registers a
reservation set that includes all the bytes of the memory location using the LR instruction.
A subsequent wrs.sto instruction would cause the hart to temporarily stall execution in a
low-power state until a store occurs to the reservation set or an interrupt is observed.
Sometimes the program waiting on a memory update may also need to carry out a task at a future time
or otherwise place an upper bound on the wait. To support such use cases, wrs.sto bounds the
stall duration to an implementation-define short timeout such that the stall is terminated on the
timeout if no other conditions have occurred to terminate the stall. The program using this instruction
may then determine if its deadline has been reached.
wrs.sto causes the hart to temporarily stall execution in a low-power state as long as the reservation
set is valid and no pending interrupts, even if disabled, are observed. For wrs.sto the stall duration
is bounded by an implementation defined short timeout. These instructions are not supported in a
constrained LR/SC loop.
Hart execution may be stalled while the following conditions are all satisfied:
a. The reservation set is valid
b. If wrs.sto, a "short" duration since start of stall has not elapsed
c. No pending interrupt is observed (see the rules below)
While stalled, an implementation is permitted to occasionally terminate the stall and complete
execution for any reason. wrs.sto follows the rules of the WFI instruction for resuming execution
on a pending interrupt. Since wrs.sto can complete execution for reasons other than stores to
the reservation set, software will likely need a means of looping until the required stores have occurred.
The duration of a wrs.sto instruction's timeout may vary significantly within and among implementations.
In typical implementations this duration should be roughly in the range of 10 to 100 times an on-chip
cache miss latency or a cacheless access to main memory.
Description from riscv-unified-db, reformatted.
Operation
# wrs.sto has an implementation-defined short timeout that guarantees # forward progress, so TW/VTW checks are not applicable. # stall while the reservation set is valid, no interrupt is pending, # and the short timeout has not elapsed wrs_sto();
Pseudocode in riscv-unified-db’s IDL, quoted unchanged.