Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

De-jankify select() call #4

Open
brian-armstrong opened this issue Dec 30, 2017 · 1 comment
Open

De-jankify select() call #4

brian-armstrong opened this issue Dec 30, 2017 · 1 comment

Comments

@brian-armstrong
Copy link
Owner

brian-armstrong commented Dec 30, 2017

The merging of posix-style select() call with Go seems pretty jank, at least in this implementation. The select() has a 1-second timeout, so that if there are no pins changing, it takes up to a second to add and remove new pins to the watcher https://github.com/brian-armstrong/gpio/blob/master/watcher.go#L112 and https://github.com/brian-armstrong/gpio/blob/master/watcher.go#L193

We should investigate if it's possible to remove these in some way without impacting CPU.

One possible option, though sort of gross, would be to open a file in /tmp (or a socket) and have our select() call include it in its readfds. Then a goroutine could write to this file descriptor in order to wake up the select() caller, which could then do maintenance like adding/removing pins or closing. If we did this, we could possibly remove the 1-second timeout entirely, allowing us to sleep more while having very good latency for these sorts of operations.

@temoto
Copy link

temoto commented Jan 31, 2019

@brian-armstrong poll syscall could fix timeout granularity problem.

Thanks for (maybe best to date?) GPIO library with edge event support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants