Chapter Contents

Previous

Next
All-Resident C Programs

Introduction

Normally, when a C program is linked, the resulting load module does not contain all of the support routines needed by the program. For example, before the program's main function is entered, the command line must be parsed and the argv vector created. Because the command-line parsing routine is only needed once, during program start-up, the program initialization routine dynamically loads it from the transient library and unloads it (freeing the memory it required as well) when it is no longer needed.

In most programming situations, the dynamic loading and unloading of support routines makes the best use of available resources. User storage is not occupied by unused code, and when the support routines are installed in shared memory, many users can access a single copy of the routine. Also, the load module is much smaller because it contains only a small percentage of the required code.

However, in certain specialized applications and environments, it may be desirable to force the program load module to contain a private copy of all the required support routines. These programs can be characterized as all-resident programs because no transient library routines need be used. The following sections describe how to create all-resident programs.

The rest of this chapter is divided into five sections. The first section describes the organization of the all-resident library, that is, what each collection of support routines is for and how they are grouped. The second section shows how the <resident.h> header file can be used to specify which support routines are needed by an all-resident program. The third section lists some restrictions that apply to all-resident programs. The fourth section discusses several programming considerations. The last section tells you where information about linking all-resident programs can be found in this book.

Throughout this chapter, support subroutines are referred to as routines rather than functions in order to prevent confusion with library functions such as strcpy .


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.