Article View: comp.os.os2.programmer.misc
Article #8Re: Q: How do DLLs and threads work in OS/2? (VX-REXX)
From: Andy Stritof
Date: Thu, 19 Oct 1995 20:22
Date: Thu, 19 Oct 1995 20:22
40 lines
2593 bytes
2593 bytes
Carsten Whimster (bcrwhims@undergrad.math.uwaterloo.ca) wrote: [snip - description of setup and test] : What gives? I was just warned that static variables in a DLL aren't : thread-safe, but maybe I am misunderstanding something here. It seems : to work the way I wanted it to, without any changes, whereas I was : expecitng to have to write some kind of initialization routine for : each instantiation of an app using the DLL. You have two processes running here and the default for links on DLLs is for each process to have its own memory area (a DATA NONSHARED line in the .def file) - you can change that and then you should see the behavior you were expecting. As to static variables not being thread safe, I don't know. Threads share global data areas within a process and if its important to keep the threads from trouncing each other, you can serialize access to data with semaphores or other methods (saw an example once where threads were controlled with message Qs instead of semaphores). : What should I do? Just write and use it the way it is, or rewrite it : in some other way, without static variables? In the second case, what : is the methodology I should use, ie. what basic algorithm works here? In the scenario you described, nothing. If you wish to have each process access the same data, consider using a shared memory area outside the dll (that would prevent a second init from wiping out the count) or share the data area of the dll (I'd use shared mem most of the time - all depends on the situation) : Does this have something to do with the contents of the lnk file? The def. Cheers! -- *-------------------------*---------------------------------------------* * Andy Stritof | Transport of implements of husbandry wider * * stritof@xnet.com | than 8 ft. 6 in. beyond this point is * * | strictly prohibited. * *-------------------------*---------------------------------------------*
Technical Details
Message-ID:
<466c2l$1bt@flood.xnet.com>Path:
arc1-ca.pugleaf.net!news.xnet.com!stritofReferences:
<DGp9xA.2Hw@undergrad.math.uwaterloo.ca>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.xnet.com!stritof From: stritof@flood.xnet.com (Andy Stritof) Newsgroups: comp.os.os2.programmer.misc,comp.lang.rexx Subject: Re: Q: How do DLLs and threads work in OS/2? (VX-REXX) Followup-To: comp.os.os2.programmer.misc,comp.lang.rexx Date: 19 Oct 1995 20:22:45 GMT Organization: XNet - A Full Service Internet Provider - (708) 983-6064 Distribution: inet Message-ID: <466c2l$1bt@flood.xnet.com> References: <DGp9xA.2Hw@undergrad.math.uwaterloo.ca> NNTP-Posting-Host: monsoon.xnet.com X-Newsreader: TIN [version 1.2 PL2]