riscv-plic-spec icon indicating copy to clipboard operation
riscv-plic-spec copied to clipboard

[Question] PLIC priorities and interrupt selection

Open sajjadahmed677 opened this issue 3 years ago • 1 comments

Hello everyone! I have question regarding plic interrupt priorities and interrupt selection. According to plic documentation. it selects interrupts based on priorities if there are multiple interrupts, the interrupt with highest priority will be serviced. But, here comes the confusion. how it is possible to have multiple interrupts at the same instant of time in single hardware thread environment. we know that our high level language is sequential in nature. lets take an example. i have two API's for gpio and spi.

int main() { int a, b; a = gpio_read(); b = spi_read(); } in above example a will have the value of any gpio pin and b will have value read from spi. whenever i call the gpio_read it will configure gpio modue, plic and core for interrupts and after handing it will disable them. same goes for spi, because the code is sequential in nature i wont get any interrupt from spi until gpio is serviced. so, my question is in which condition we can have multiple interrupts at same instant of time in single thread environment??

sajjadahmed677 avatar Apr 23 '21 20:04 sajjadahmed677

@sajjadahmed677 Multiple interrupts won't be triggered to the single thread (only one context) at the same time because the Interrupt Claim register is context-based. See https://github.com/riscv/riscv-plic-spec/blob/master/riscv-plic.adoc#interrupt-claim-process. The second interrupt would be triggered to the target context once the Interrupt Claim Process is finished for the first interrupt.

changab avatar Apr 03 '22 15:04 changab