NXC: multithreading: variable access conflict?

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: multithreading: variable access conflict?

Post by HaWe »

I'm storing all values on each slave in a
long varray[13] or varray[16],
on my master I have a matrix
long vmarray[3][13] (or [3][16])
for all collected data of all 3 slaves.

further processing of the data on the master makes it easier (and more systematic and more flexible) to have this matrix than to have individual structures, because I simply can poll all remote sensor and variable data from all slaves by only 2 nested "for"- loops
- or -
I may poll and process individual data from each slave by
long GetRemoteValue(char slvID, char slot) {return vmarray[slvID, slot];}

Changing the assignment and the sequence of the attached sensors and the series of bits, bytes, ints and longs on any slave (if necessary) makes it easier for me to have a universal array of long integer instead of having to process different structures on and from each slave (and additionally have to redesign then the BT send/receive routines on slave or master). Instead, my current "compressed-string-encoding" allows the order of values to remain very flexible (I hope you understand what I'm trying to express) - and of course I use the mailbox system for this.

So I will probably "insist" on the "universal arrays" if you won't mind
;)

ps: to clarify, ;) <<<<< is not offending :)
- but now I have to be careful not to become OT^^

edit1: so back to topic, I now took the mutexes only for write operations where conflicts may actually occasionally occur and dropped the rest.

edit2: After changing my code it turned out that array/read/write conflicts were not the reason why the arrays/message strings often become corrupted before, during, or after BT send/receive tasks - I will have to work on BT error checking instead further more.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 0 guests