[comp.binaries.ibm.pc.d] Changing CONFIG.SYS on the fly

porter@caip.rutgers.edu (Adam L. Porter) (02/24/89)

How can I swap device drivers in and out without rebooting?

Thanks...

					-Adam

dixon@sagittarius.steinmetz (walt dixon) (02/24/89)

It is fairly easy to add new device drivers (both block and character)
on the fly (ie after the system has booted --  no reboot required).
The basic mechanism involves plugging into the relevant dos data structures.
Character drivers need only to link into the list of device headers.
Block drivers must do more work.  DOS builds current directory structure
(CDS) and device control block entries (DCBs) for each block device.

To load a driver on the fly,  you must either write a driver load utility
or build this intelligence into your driver.  I've done both succesfully.
NB It is possible to write a program which either loads as a driver
(from CONFIG.SYS) or executes a TSR function when invoked from COMMAND.COM.

Unloading drivers reliably is much more difficult.  One has no way of
absolutely knowing which programs /TSRs have referenced a device.  DOS
maintains information on handle access in a central data structure --
the System File Table (SFT).  There still is the nagging question of
what one does about a program with an outstanding reference.  Terminate
it?... FCB access posses another set of problems.  Although DOS maintains
a SFT for FCB access,  there is no guarantee that all FCB access will
have records in this table.  DOS moves context information between the
FCB SFT and a programs FCB.  Needless to say,  one must flush the cache
for block devices.

Summary:  New devices can be added easily at any time provided you have
adaquete resources.  Don't try to replace existing devices unless you
are absolutely sure about outstanding references.  For further information
read chapters 10 and 11 of "The MS-DOS Papers" (Howard Sams,  1988) and
chapter 4 of "The MS-DOS Developer's Guide, 2nd Edition" (Howard Sams, 1988).
I am the author of these chapters.  I don't get any royalties for book sales;
I'm just citing a good reference.

Walt Dixon		{ARPA:		dixon@ge-crd.arpa	}
			{US Mail:	ge crd			}
			{		po box 8		}
			{		schenectady,  NY 12345	}
			{Phone:		518-387-5798		}