There is no such thing as interrupt handling in Linux userspace - interrupt handling is all done within the kernel. The gpiochip device API makes edge events available which will wake the waiting app whenever events occur.
I haven't looked into the guts of lgpio, but in my testing it burns CPU just to monitor a pin.
I'm guessing it is polling the line in a background thread rather than using the edge events available from the gpiochip device.
The lowest overhead approach is to use gpiod, as per this example. That uses zero CPU while waiting for events. It will block your app until edge events are available. If you have other things to be doing in your app then put the event handling in a Python thread and only that thread will block waiting for events.
I haven't looked into the guts of lgpio, but in my testing it burns CPU just to monitor a pin.
I'm guessing it is polling the line in a background thread rather than using the edge events available from the gpiochip device.
The lowest overhead approach is to use gpiod, as per this example. That uses zero CPU while waiting for events. It will block your app until edge events are available. If you have other things to be doing in your app then put the event handling in a Python thread and only that thread will block waiting for events.
Statistics: Posted by warthog618 — Sat Sep 14, 2024 5:32 am