DLL static data

rag84dec's Avatar, Join Date: Jul 2007
Go4Expert Member
Hi all,
I have static data members in the class
I have written to form static libraries.These static libraries are
used to form a Dynamic link library.
Do i need to use SEMAPHORE wile using those static data??
Can you please help me in understanding this with an
example?...Do i need to use semaphore at any other place??

Thanks
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
You don't need any kind of mutexing arrangement just to access static data.
If you want to update any kind of data (not just static) in a multithreaded program then you need to serialise access so that different threads do not clash, e.g.:
thread 1: read memory, get value 1
thread 2: read memory, get value 1
thread 1: increase value and write back, storing 2
thread 2: increase value and write back, storing 2

Here we see that two threads have updated the same number, and the result should be 3.