top of page

Using Dynamic Link Library (DLL) on NonStop

Writer's picture: Donald WickhamDonald Wickham

Updated: Dec 29, 2022

DLLs (Dynamic Link Library) have long been used to provide optional features to programs since its inception on the Windows platform. TIC has used this capability in our Windows™ applications, TelePath and TICTransform.  DLLs allow customers to extend both of these TIC products by adding their own code. But did you know that DLL is also available on the NonStop? If fact, DLLs have been available for the NonStop platform now for a few years.


Why use DLL?

For statically linked programs, you must copy all shared libraries into your own programs; thus, complete copies of these libraries appear in all the programs that use them, and each copy consumes main memory and disk space. Also, whenever such a library is changed, it must be relinked into all the programs that need those changes.


On the other hand, if you use DLL, here are some benefits, as stated in the documentation:

  • A single copy of a DLL in physical memory can be shared among multiple processes.

  • A DLL that is shared among processes can appear at a different virtual address in each process and each instance has its own copy of global data that is available to its process.

  • Multiple processes can use different versions of the same DLL simultaneously, though each version must have a different name or be stored in a different location in the file system.

  • The same program can run simultaneously in different processes with different DLLs supplying the supporting data and functions.

  • A new version of a DLL can be introduced without having to alter a program or DLL that references it.

  • A running application can cause a DLL to be loaded dynamically and to make its functions and data accessible.

Explicit versus Implicit

On the Nonstop there are “explicitly linked” and “implicitly linked or programmatically loaded” DLLs.  Most DLLs are explicitly linked, where the DLL is referenced when the program is being linked.  Implicitly linked or programmatically loaded is just what the name implies, the DLL is loaded via a call to an API method.


Recently we have been able to utilize the implicit linking capabilities of DLLs.


Thunder Suite, a third-party tool that TIC provides to the NonStop market, provides services to create and parse XML documents.  Thunder Suite creates source code that is compiled and bound into customer applications.  Since these source code modules, called handlers, are completely self-contained, they lend themselves to being used in implicitly linked DLLs.  A project was started to explore how that could be done.


It turned out to be fairly straight forward.  By wrapping the Thunder Suite handlers in a common function, each handler could be called on an as-needed basis.  This is accomplished by doing a programmatic load of the DLL containing the appropriate handler and a call to a common function.


Our DLL Experience

We’ve discovered some things about doing this that we felt would be helpful to share.

  • Have a common function that is exported (made available) in each of the DLLs.  This function must have the same API or signature in all the DLLs.

  • The DLLs are written in C/C++ to enable finer control of variable length structures.  The returned structures from the DLL are allocated by the DLL since it alone knows how big they are, and released by the calling program.

  • A word of caution: Any trap that occurs in the DLL causes the whole program to trap and abend.  A try-catch block cannot prevent this.

Summary

Using DLL in your NonStop programs can provide additional flexibility in extending your code. In some ways the implicitly linked DLLs are similar to the requester-server model we are all familiar with.  By having a separation of function between the requester and server, changes can be made to either without impacting the other.  Implicitly linked DLLs provide a similar separation and flexibility.  Modularly independent, loosely coupled design has long been a standard and implicitly linked DLLs provide that.

 

Feedback please

Do you find this tutorial blog helpful? Let us know what you think, and how we can make it even better. Don’t forget, you can subscribe to our blogs to get automatic email notification when a new blog is available.

 

Donald Wickham has 31 years experience with Nonstop including 20 years for Tandem, Compaq and HP. He has been with TIC Software for 11 years in the role of Chief Architect.


 

TIC Software, a New York-based company specializing in software and services that integrate NonStop with the latest technologies, including Web Services, .NET and Java. Prior to founding TIC in 1983, Phil worked for Tandem Computer in technical support and software development.

Comments


Categories

Archive

bottom of page