Home » U++ Library support » U++ MT-multithreading and servers » Use same variable in different threads
Re: Use same variable in different threads [message #30117 is a reply to message #30116] |
Thu, 09 December 2010 18:57 |
|
Hi Koldo,
From my little knowledge (close to yours probably ):
Atomic is just typedefed int, which can be manipulated by U++ functions Atomic{Read,Write,Inc,Dec,XAdd}(). They are implemented using atomic operations, so it should be guaranteed that the return value is correct even if other thread changes value of the variable while processing the function call.
Volatile tells compiler that the variable can be changed from other threads, so that compiler knows that the generated code must check for its value everytime, instead using for example value stored in cpu cache, because other thread might have changed since it was stored there.
Mutex is a mechanism that allow you to lock some code so that if other code gets to the same section it has to wait for the first one to leave. This is utilized by INTERLOCKED macro in U++.
RWMutex is a variant of mutex that allows you to mark "read code" which can be executed by any number of threads at once and "write code" that can be executed only by one thread at a time and no thread can run in write mode until all reading threads are finished.
Hope that at least some of it helps... It definitelly helped me to sort it out in my head
Best regards,
Honza
|
|
|
|
|
Use same variable in different threads
By: koldo on Thu, 09 December 2010 18:26
|
|
|
Re: Use same variable in different threads
|
|
|
Re: Use same variable in different threads
By: koldo on Thu, 09 December 2010 22:04
|
|
|
Re: Use same variable in different threads
By: Didier on Fri, 10 December 2010 00:26
|
|
|
Re: Use same variable in different threads
|
|
|
Re: Use same variable in different threads
By: koldo on Fri, 10 December 2010 10:01
|
|
|
Re: Use same variable in different threads
|
|
|
Re: Use same variable in different threads
By: koldo on Fri, 10 December 2010 13:19
|
|
|
Re: Use same variable in different threads
|
|
|
Re: Use same variable in different threads
|
|
|
Re: Use same variable in different threads
|
|
|
Re: Use same variable in different threads
By: Didier on Fri, 10 December 2010 18:50
|
|
|
Re: Use same variable in different threads
|
|
|
Re: Use same variable in different threads
By: Didier on Sat, 11 December 2010 23:13
|
|
|
Re: Use same variable in different threads
|
|
|
Re: Use same variable in different threads
By: mirek on Sun, 12 December 2010 09:43
|
|
|
Re: Use same variable in different threads
By: koldo on Sun, 12 December 2010 23:16
|
|
|
Re: Use same variable in different threads
By: tojocky on Mon, 13 December 2010 11:35
|
|
|
Re: Use same variable in different threads
|
|
|
Re: Use same variable in different threads
By: Didier on Mon, 13 December 2010 22:48
|
|
|
Re: Use same variable in different threads
By: koldo on Tue, 14 December 2010 09:02
|
|
|
Re: Use same variable in different threads
By: mirek on Sat, 25 December 2010 20:45
|
|
|
Re: Use same variable in different threads
By: tojocky on Sun, 02 January 2011 15:35
|
|
|
Re: Use same variable in different threads
By: mirek on Sun, 02 January 2011 18:38
|
|
|
Re: Use same variable in different threads
By: koldo on Sun, 02 January 2011 19:06
|
|
|
Re: Use same variable in different threads
By: mirek on Sun, 02 January 2011 22:56
|
|
|
Re: Use same variable in different threads
By: koldo on Mon, 03 January 2011 09:17
|
|
|
Re: Use same variable in different threads
By: koldo on Sun, 02 January 2011 01:12
|
|
|
Re: Use same variable in different threads
|
|
|
Re: Use same variable in different threads
By: Didier on Sun, 02 January 2011 12:18
|
|
|
Re: Use same variable in different threads
|
Goto Forum:
Current Time: Thu May 09 12:08:05 CEST 2024
Total time taken to generate the page: 0.01733 seconds
|