-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Use on platforms that have no mutexes #21
Comments
Mutexes can also make sense in a cooperate scheduling world. For example, Boost's |
Not really, since I am not running (and not planning to run) more than a single thread anyways. The platform I am working on doesn't really have well documented multithreading anyways. Came across a couple of undocumented error codes last time I tried. 😆 But yes, you are right, mutexes make sense if you are doing multithreading even on cooperative systems. Took me a while to realize. |
Even on a single thread, they can make sense. The following code without mutexes could have the same issue concurrency could: auto x = this->m_something;
co_await check_something (x);
this->m_something = std::move (x); ... as check_something suspending could lead to another coroutine that uses |
In this case you'd use an You could define a custom platform header ( |
Ah, right. Terminology confusion, my bad. I thought the issue is about the |
So I eliminated all std::mutex occurencies by hand, just for giving it a try, however it seems like the platform I am targeting doesn't support atomics either. And these seem to be absolutely mandatory. :-/ |
Which platform is this? |
It's armv5te (through devKitPro). :-) |
what compiler does that use? I'm unaware of any platform that omits atomics (and the standard, AFAIK, doesn't permit that anyway) |
It's latest GCC. I think they share the STL headers between all targets and just vary the underlaying library. |
AFAIK, the GCC arm5te target provides atomics. I'll need more info, or compiler access, to be able to debug further why they might not be present. Alternatively, we could have a platform::atomic that we can switch between some dummy class and std::atomic via the custom platform mechanism, but this very much feels like a toolchain problem |
I am going to ask in the devKitPro forum and come back here if they were able to tell me anything useful :-) |
Sure, keep us posted. Also, out of curiosity, could you post the error that you get due to a lack of atomics? |
|
Ah, I see. In this case, depending on your system, you're likely best off implementing a libatomic-esque library suited for your environment. If this is a non-SMP environment, that could be as simple as temporarily turning off interrupts or something like that. With LTO, that could probably optimize to a regular load/store (plus whatever interrupt handling you add). This might be a worthy inclusion in devkit too. |
Hey!
I was attempting to use this library on a plaform that doesn't have preemptive multithreading (it's cooperative) and therefore no mutexes. Libasync however really seems like it wants mutexes.
I could probably write a fake mutex class, but that seems like a dirty option. Is there a way to just tell libasync to not use mutexes?
Thanks
niansa
The text was updated successfully, but these errors were encountered: