18.2.4 Segment Strategy in a DLL

Be careful how you place different kinds of data and code in different segments. When loading the DLL, OS/2 checks to see if the DLL is already in memory. If so, it loads only new copies of NONSHARED segments; it does not reload SHARED segments. Code segments are always SHARED.

Control of DLL data and code works at the segment level. The DATA statement assigns default attributes for all data segments in the DLL, but the module-definition SEGMENTS statement overrides these attributes for any given segment.

You may want to create a DLL that has some data shared between all programs that call the DLL and some data that is private to each instance. The following module-definition statement specifies that all data in GLOBDAT is shared and all data in PRIVDAT is not:

SEGMENTS

GLOBDAT SHARED 'data'

PRIVDAT NONSHARED 'data'

The segments have class `code' unless you specifically define the class as shown in this example. See Section 18.4.1 for more information on module-definition files.