Follow

"Wait for Interrupt instruction (WFI) provides a hint to the implementation that the current hart can be stalled until an interrupt ... so a legal implementation is to simply implement WFI as a NOP" 🤔

Source: github.com/riscv/riscv-isa-man

@exa I have some code that assumes WFI will loop forever. I suppose that's incorrect 🤔

@lupyuen if by "loop forever" you mean "the hart isn't going to execute past the WFI instruction", then yeah that code might be wrong

@lupyuen anyway I guess fixing this with 1 extra instruction that loops forever over the WFI is quite valid. I assume your interrupt handler will be able to jump over that, right?

@lupyuen Too bad they didn't call it "May Wait For Interrupt" (MWFI). :/

@lupyuen Wait For Interrupt would be a conditional NOP wouldn't it? Perhaps it's fine, but it just seems wrong to use it like that. Not wrong as in it won't work but wrong as in it works and that's fine.

@AmpBenzScientist

No, the whole point of an interrupt is that it isnt a conditional NOP.

@lupyuen

@freemo @lupyuen It makes more sense when I look at an RTOS. It also makes sense why it's in the Privileged category.

A few NOPs exist in RISC-V but it's rather clever that WFI would be used instead of NOP. It should allow time sensitive operations to run as soon as they become ready.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.