Hi sonofcy, thanks. Using any Arduino architecture core (not python please) please provide an example of how this threadsafe-shared-memory is setup and written/read please? Perhaps this is exactly what I'm not getting. Or maybe this is something platform/architecture/core specific?
As for a code example, I just can't get anywhere near code without seeing a problem having to turn 120 degrees, and throw it in the bin.
The problem is still best described by.
- abstract problem, abstract code
- re-usably implementing thread safety in one place
- its for a simple problem:- multiple tasks all reading and writing to something which is like 'some' global data structure/object, but its not a complex resource like protocolling with a shared hardware interface or some such.
You certainly can't just declare and use a global variable, or any structure made from ordinary storage/memory datastructures/variables, because its not threadsafe. Its harder to work out if its going to be safe, than it is just to assume its not safe. (could be interrupted any time, data could be in a half complete state as its read form address 'a' up to 'b' > overwritten elsewhere, and then finally read from 'b'-'c', then if you start making flow decisions based on that you could find yourself in a race condition. There is no point in testing, these problems can manifest very rarely, but unless your ok with ("1+1 sometimes equals 'whatever'" then they are still fatal) That's just the stuff I know about, never mind the stuff I don't.) Its easier just to assume its not safe. But I don't think that's what your suggesting.