oc2 icon indicating copy to clipboard operation
oc2 copied to clipboard

A hook-based way to use redstone interface

Open heipiao233 opened this issue 1 year ago • 5 comments

Is your feature request related to a problem? Please describe. Sometimes we have to listen many redstone interfaces, so we can do it through polling. But this way is very slow, and if we are listening for short redstone signals like a button, the program may cannot receive the signal.

Describe the solution you'd like Keep the old way, and add a new way: when the interface receives signal, call the hook function.

Describe alternatives you've considered No

heipiao233 avatar Sep 25 '22 07:09 heipiao233

This is impossible with the RISC-V architecture since the OS manages all I/O, devices cannot force the CPU to jump to a function unless it's an interrupt, in which case you'll need a custom kernel.

atirut-w avatar Sep 25 '22 08:09 atirut-w

Is that possible if we write a driver? I just know something about it.

heipiao233 avatar Sep 25 '22 13:09 heipiao233

Would software-hooks be a viable option, or would implementing hooks on top of current system potentially lead to loss of extremely quick signals? If the program is structured well and doesn't hold control for too long, could it not do cooperative multitasking and have event handlers?

CoolCat467 avatar Sep 25 '22 18:09 CoolCat467

Basically something like an interrupt?

ajh123 avatar Feb 13 '23 12:02 ajh123

Basically something like an interrupt?

yes

heipiao233 avatar Feb 13 '23 12:02 heipiao233