Switcher API Overview
█▌Overview▐█
Starting with DOS 5.0, Microsoft published information on coexisting with
the DOS task-switcher. For most applications, actions of a task switcher
are transparent, but a few programs need to avoid the potential pitfalls
possible when they are turned off and on by an external program.
█▌Who Needs the Switcher API?▐█
Some programs need to take special precautions when running under a task
switcher. For instance, modem programs will be in big trouble if they get
switched-out while online with a remote computer. These programs can
process SwNtfyFn 0001H and indicate when switching-out would be bad news.
Some TSR programs installed before the switcher can provide different
context for each DOS session. For instance, the Doskey TSR maintains a
separate "command history" and "macro set" for each DOS session. All
sessions share the same code space, but a separate data area is maintained
for each session.
Some programs need to take precautions about the use of global resources
that may be destroyed without proper handling. For instance, a word
processor may create temporary files. Each session of the program should
maintain separate files to avoid problems.
Note: Much of the Switcher API is concerned with a situation in which
two or more switchers are active simultaneously and having them
coexist peacefully. Unless you are writing a task switcher, you
may ignore most of the API.
█▌Using the Switcher API▐█
If you need to be switcher-aware, follow these steps:
1) Use INT 2fH 4B02H to see if a task-switcher is active. This also
returns the service entry address.
2) Use INT 2fH 4B05H to identify regions of your memory which must be
maintained for each session. The switcher will automatically save
and restore these areas for each session when tasks are switched.
3) If you need to be notified of a pending task-switch (in order to
clean up before the switch or to block the switch altogether), call
the service entry address with AX=0004H to "hook" the notification
chain (see SwSrvcFn 0004H). Thereafter, the switcher will call a
designated procedure in your code before switching you out.
And remember to use SwSrvcFn 0005H later, to unhook yourself before
you terminate.
See Also: Switcher API
INT 2fH
TSR Functions
DOS Functions
-♦-