Home » U++ Library support » U++ MT-multithreading and servers » Simple class to handle variables used by different threads
Re: Simple class to handle variables used by different threads [message #45049 is a reply to message #45046] |
Mon, 24 August 2015 19:13 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
Well, depends on type and CPU...
Usually, if type is directly supported by CPU, it works.
Example of type that does not work is e.g. int64 in 32-bit mode. It is because it is, on CPU level, compound type...
Anyway, MT is not hard because of transfering data between threads. If you think about it, they have to get transfered at some point... The real issues are order:
if one thread does
a = a1;
b = b1;
then another thread can see b updated first. This is what barriers are for.
(Then, of course, there is an issue that you cannot never tell WHEN the change is visible in another thread, but that is really not a problem...)
And then, of course, serialization, which is about transactions:
a = a + 1;
now this, on CPU level is something like
read a into register
increment register // remember this point A
write register into a
Now imagine if another thread starts incrementing a at point A...
Well, there really is complex theory about lock-less multithreading, it is pretty tough stuff. I would not dare suggesting new MT tools before reading it all
Mirek
|
|
|
|
|
Simple class to handle variables used by different threads
By: koldo on Fri, 21 August 2015 13:41
|
|
|
Re: Simple class to handle variables used by different threads
By: Klugier on Sat, 22 August 2015 14:00
|
|
|
Re: Simple class to handle variables used by different threads
By: koldo on Sat, 22 August 2015 16:08
|
|
|
Re: Simple class to handle variables used by different threads
By: mirek on Sun, 23 August 2015 20:34
|
|
|
Re: Simple class to handle variables used by different threads
By: koldo on Mon, 24 August 2015 09:05
|
|
|
Re: Simple class to handle variables used by different threads
By: mirek on Mon, 24 August 2015 11:34
|
|
|
Re: Simple class to handle variables used by different threads
By: koldo on Mon, 24 August 2015 15:05
|
|
|
Re: Simple class to handle variables used by different threads
|
|
|
Re: Simple class to handle variables used by different threads
By: mirek on Mon, 24 August 2015 19:13
|
|
|
Re: Simple class to handle variables used by different threads
By: koldo on Tue, 25 August 2015 00:13
|
|
|
Re: Simple class to handle variables used by different threads
|
|
|
Re: Simple class to handle variables used by different threads
By: mirek on Tue, 25 August 2015 15:44
|
|
|
Re: Simple class to handle variables used by different threads
By: koldo on Tue, 25 August 2015 17:04
|
|
|
Re: Simple class to handle variables used by different threads
|
|
|
Re: Simple class to handle variables used by different threads
By: koldo on Tue, 25 August 2015 22:45
|
|
|
Re: Simple class to handle variables used by different threads
|
|
|
Re: Simple class to handle variables used by different threads
By: koldo on Wed, 26 August 2015 07:24
|
|
|
Re: Simple class to handle variables used by different threads
|
Goto Forum:
Current Time: Mon Apr 29 00:58:42 CEST 2024
Total time taken to generate the page: 0.04550 seconds
|