-
Notifications
You must be signed in to change notification settings - Fork 53
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
Better waitEvents implementation for *nix-like systems #53
Comments
I'm beginning to see the problem. |
PS: The event thread pooling every 100ns so in the small device use 100% of the CPU. Tested on a Onion Omega. See LinuxEventThread |
The only way of resolving indefinite blocking that I can think of is using |
So, I removed 100ns sleep and instead added these two lines (from jSerialComm with added explicit cast) to waitEvents:
I left the rest of the code unchanged. So now it times out every second if nothing comes, checks if EventThread has been interrupted, then waits again. I didn't bother doing messaging between Java and JNI to interrupt indefinite It's interesting that Here's the relevant commit. Not sure if it's worth including here though, I still don't fully know what I'm doing. |
I'm also seeing pretty high CPU usage even during idle. any chance we can get this merged and released? |
vs.
Probably best to wait for proper review, which no one's volunteered to do, so it'll wait until I hire someone, or someone volunteers. 🍻 |
thanks all for the responses. Just to add some testing results info. I did build and test this on Debian 9 with ARM chipset with Octavo processor and did verify that the CPU dropped quite dramatically. Functionally, everything appears to be correct still when communicating over the serial ports. I will continue to monitor for a long time and report back if I see anything strange. |
@graynk do you mind opening a PR? |
Sure, no problem. I'll take a look at the merge conflicts tomorrow, and open a PR once I resolve them |
Reopening per @centic9 comments in #78 (comment). |
jssc/src/cpp/_nix_based/jssc.cpp
Line 716 in 0d0e6f7
So, this line mentions that there's no analogue for
WaitCommEvent
from WinApi. However, isn't that whatpoll
/epoll
/select
functions are for? My concern is that for me using this library on Linux causes a memory leak and garbage collection around every 30 seconds (with default flags) when the app is just idle, and I don't think there's a good reason for that.On Windows this behaviour is not present, of course. Now, I have zero experience with C++ code, so I probably shouldn't try to make a PR with critical code, but could someone take a look at it? Here's the example on SO of using
poll
on serial port and it's very close to what jSerialComm does:Then there's this blogpost with three different implementations. I just don't know how to connect all that to JNI and what to do with all the lines statuses.
The text was updated successfully, but these errors were encountered: