Hello,

Can I have a parallelised section of code, that uses x threads, where a function is called to manipulate an array. Each thread's function tries to manipulate the same array at the same time (not in the same location in the array).

[for example, take a 2x2 matrix (x(and y) start at 0 and end at 1), and a function calculates the value of that matrix as a sum of the x location and the y location, (so x=0 y=0 output=0, x=1 y=0 output=1, x=1 y=1 output =2). Can I parallelise this so that, it calculates each field at the same time, but manipulating the a single array.]

Is this possible?

(Hopefully this is clear enough, if you require more detail please tell me.)

Thanks in advance.

Generally speaking when you use threads to modify/read global data, you use some form of lock to assure that the data isolated to the modifying/reading thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.