Fixing Code and Data Segment

Any code segments or data segments a driver accesses at interrupt time must be fixed segments. For best overall system performance, you should minimize the amount of code and data in fixed segments. To minimize the amount of fixed code, isolate all interrupt-time code in a few source modules and put this code into a single fixed-code segment. Unless your driver has a large amount of data not accessed at interrupt time, use a single fixed-data segment.

The data segment _TEXT is used as a safety measure. The compiler places code for which you do not specify a segment in the _TEXT segment. This way, any code that is missed will be placed into a single segment, preventing possible problems at interrupt time. If you use fixed segments, you should check your segmentation to ensure that only code that is required to be FIXED goes into the FIXED code segment.

The Bravado video-capture driver is a medium-model DLL, using a single data segment and multiple code segments. The following example fragment is from the module-definition file for the Bravado device driver:

CODE        MOVEABLE  DISCARDABLE  LOADONCALL
DATA        FIXED  SINGLE  PRELOAD

SEGMENTS    _TEXT   FIXED                    PRELOAD
            INIT    MOVEABLE   DISCARDABLE   PRELOAD
            VCAP    MOVEABLE   DISCARDABLE   PRELOAD
 

This example fixes the data segment and the code segment named _TEXT. All other code segments are moveable.