OS/2 system services are requested by application programs using function calls; the external code references generated by such calls are resolved when the program is loaded or when the segments of the program are loaded, rather than at link-edit time. This deferred resolution of external references is known as dynamic linking, and is available to applications, which may incorporate their own routines into dynamic link libraries (DLLs).
Dynamic linking may be achieved in two ways under OS/2;
Load-time dynamic linking is the simplest mechanism; as already mentioned, OS/2 system services are implemented in this way. Load-time dynamic linking is used whenever an application developer wishes to provide common services that may be used by multiple applications, and which are implemented independently of the applications that will use them. Run-time dynamic linking is used where particular routines may or may not be used by an application, and thus should not be loaded into memory unless required. If an application requires that such a routine be executed, the application may then explicitly load the routine and execute it.
Dynamic linking provides an architected method of extending the services of the operating system; all of the application programming interfaces supported by OS/2 are implemented using dynamically linked modules. An application developer may use the same facilities to create his or her own dynamically linked modules to provide additional services or standard routines that may be used by applications executing in the system.
Dynamic linking is of benefit in that routines contained in DLLs are completely independent of application code, and may be modified without the need to re-link applications. In this way, DLLs contribute to the containment of change within applications. In addition, the contents of DLLs are not limited to application code. Presentation Manager resources such as icons, bitmaps, graphics fonts, window definitions etc, may be generated and stored in a DLL for subsequent use by applications. See Presentation Manager Resources for a further discussion of Presentation Manager resources. DLLs thus provide a powerful mechanism for the creation of reusable modules for both full-screen and Presentation Manager applications.
Secondly, the creation of DLLs as re-entrant routines reduces the storage requirements for OS/2 applications, since multiple applications may make use of the same memory-resident copy of a DLL. This re-entrancy and reusability, in conjunction with the code independence gained by using a DLL, makes the DLL a useful vehicle for implementation of standard service routines, which may be accessed by any application or process within the system. This contributes to standardization within the business organization, which in turn can result in improved productivity and reduced maintenance effort since the code to implement a particular function need reside in only one location.
Note that a DLL is not a process under OS/2. The re-entrant nature of a DLL allows multiple applications to use the same memory-resident copy of the code; however, each instance executes under the control of the process that invoked it.