Article View: comp.os.os2.programmer.misc
Article #7Q: How do DLLs and threads work in OS/2? (VX-REXX)
From: Carsten Whimster
Date: Thu, 19 Oct 1995 14:36
Date: Thu, 19 Oct 1995 14:36
36 lines
2340 bytes
2340 bytes
I have a DLL which has a static structure with a char string and an
integer, and I have a VX-REXX front-end which is calling this. Every
time a copy of the VX-REXX app starts up, it calls an init function in
the DLL, which sets the integer (count) to 0. Then each time it calls
another function in the DLL (ppGetParm()), it gets back the number of
times ppGetParm has been called. This function is called by a button,
which displays the number on the face of itself.
All of this works fine.
Then I started up a copy of the VX-REXX app, pressed the button (which
gets the count and displays it on the button face) a few times. Then I
started up another copy of the VX-REXX app, expecting the init it
calls to zero the count. The strange thing is that I was only doing
this to verify that threads don't work well with static variables in a
DLL, but as it turned out, it worked! That is, the first app kept its
own count correctly when the button was pressed, but the new version
of the app started at 0, and then counted correctly too!
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.
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?
Does this have something to do with the contents of the lnk file?
--
Carsten Whimster bcrwhims@uwaterloo.ca
EDM/2 Associate Editor and Book reviewer
Team OS/2 POV-Panel/2 author
http://www.undergrad.math.uwaterloo.ca/~bcrwhims/
Technical Details
Message-ID:
<DGp9xA.2Hw@undergrad.math.uwaterloo.ca>Path:
arc1-ca.pugleaf.net!undergrad.math.uwaterloo.ca!bcrwhimsShow Full Headers
Complete Article Headers
Newsgroups: comp.os.os2.programmer.misc,comp.lang.rexx Path: arc1-ca.pugleaf.net!undergrad.math.uwaterloo.ca!bcrwhims From: bcrwhims@undergrad.math.uwaterloo.ca (Carsten Whimster) Subject: Q: How do DLLs and threads work in OS/2? (VX-REXX) Message-ID: <DGp9xA.2Hw@undergrad.math.uwaterloo.ca> Sender: news@undergrad.math.uwaterloo.ca (news spool owner) Date: Thu, 19 Oct 1995 14:36:46 GMT Nntp-Posting-Host: cayley.uwaterloo.ca Organization: University of Waterloo