Sunday 20 November 2011

My program is too big to run under DOS. How can I make it fit? in C programming

My program is too big to run under DOS. How can I make it fit?

When your application has grown too large for DOS (over 640KB), there are two good ways to give your program more memory. One way is to use an overlay manager. An overlay manager will manage the modules (.obj files) of your program and read them in from disk and discard them as needed. This way, your program can be several megabytes in size and still fit in a computer that has only 640KB of memory available. Some advanced overlay managers enable you to determine module “groups” that you would like to be read in and discarded all together. This helps you fine-tune your application for performance reasons. Other less advanced overlay managers do not have this feature and do not enable you to fine-tune which overlaid modules should be treated as a group. Another way to get more memory for your application is to use a DOS extender. A DOS extender is a special application that uses the protected mode features of 386, 486, and newer computers to access several megabytes of memory in one flat address space. When your program is linked with a DOS extender, the DOS extender code becomes a part of your program’s start-up code. When your program is invoked, the DOS extender is loaded and your program falls under the control of the DOS extender. All memory allocation calls are routed through the DOS extender, thereby enabling you to bypass DOS and let the extender handle the intricacies of allocating memory above the 640KB threshold.

Unfortunately, DOS extenders have some definite disadvantages. One disadvantage is that most DOS extenders have runtime royalty fees that apply when you distribute your programs. This can be quite costly, especially if you have many users. A few compilers come with royalty-free DOS extenders, but this feature is typically the exception rather than the norm. Another disadvantage of using a DOS extender is that its operation typically requires you to change your source code to access the extender’s application program interface (API) instead of using DOS calls.

Overlay managers do not typically require runtime fees, so they are more cost efficient and less expensive than
DOS extenders. Additionally, you rarely need to change your source code to use an overlay manager. Most of the time, the use of an overlay manager is transparent to the program.

Cross Reference:

XVIII.11: I get the message DGROUP: group exceeds 64KB during my link. What’s wrong?
XVIII.12: How can I keep my program from running out of memory?
XVIII.14: How can I get more than 640KB of memory available to my DOS program?
XVIII.15: What is the difference between near and far?

No comments:

Post a Comment