-
Notifications
You must be signed in to change notification settings - Fork 104
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
Threading examples #69
Comments
Standard threading APIs (i.e. pthreads, C threads, C++ threads) are all supported on the Switch (except for |
Okay, I'll try to port some code, that does not reliably work for me, so we can figure out why that is. |
I uploaded a repo with sample code and instructions here https://github.com/T4cC0re/libnx-threads-freeze It would be great if you could take a look. Most of the time it just works, but sometimes it freezes after creating a thread. That might be a bug in libnx? I don't know. It also seems to be dependant on app start. Because a restart of the same code may either work or freeze. |
int i = 0;
// Make the thread busy
while (i < 10000) {
i++;
}
return i * threadNr; This will do nothing, as the compiler will optimize it out since the loop does nothing (it will turn it into just |
Hey @fincs Thanks for taking a look. I just pushed an update, that makes reproduction a bit easier. I also added a linux target to sanity check my code. And the weird thing is, that on Linux it works flawless. So there has to be something funky in HorizonOS, libnx or the switch hardware... So I am guessing this is not the right place and this should rather be a libnx issue? |
Hey there!
I would like to request some examples of a multi-threaded application. Specifically one, that does background tasks and then joins the threads later.
I tried to do this with both libNX threads and std::thread but I cannot get the threads to work reliably (i.e. not freeze the app at random times). I cannot easily post my code without massive modifications, so I would like to take a look at a reference implementation to see what I am doing wrong.
The text was updated successfully, but these errors were encountered: