Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   DLL static data (http://www.go4expert.com/forums/dll-static-data-t15306/)

rag84dec 30Nov2008 17:21

DLL static data
 
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

xpi0t0s 30Nov2008 19:47

Re: DLL static data
 
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.


All times are GMT +5.5. The time now is 05:56.