At least from my experience, most books on DOS programming make it very clear that DOS functions are non-reentrant (because DOS only stores one statically allocated copy of the variables reflecting it's current state when executing a service). I recently read two USENET posts (https://groups.google.com/forum/#!topic/comp.os.msdos.misc/RZj2kTObqPc) that explains that getting a pointer to the Swappable Data Area (SDA) and making a copy of the SDA, executing another service, and then restoring the original SDA prior to calling a DOS service within another DOS service makes DOS capable of reentrancy.
Curious, I checked out Ralf Brown's list and found the correct DOS service (int 21h, ax=5D06h), but something struck me as interesting while reading the usage notes:
"Swapping the data area allows reentering DOS unless DOS is in a critical section delimited by INT 2A/AH=80h and INT 2A/AH=81h,82h."
Indeed, int 2Ah contains a DOS kernel service to enable/disable critical sections that does not appear to be typically used by applications. Not having access to my books about DOS internals anymore, this raises a few questions:
1. Is the DOS stack (assuming that's what STACKS in CONFIG.SYS is for) stored in the SDA?
2. What does DOS attempt to protect while inside a critical region? Is it up to the application to make sure it knows that DOS is currently in a critical region?
3. Why bother having a concept of critical regions in the DOS kernel if the application programmer is supposed to assume DOS is non-reentrant? I know multitasking libraries exist for DOS, but...
4. In the USENET post above, Ralf Brown mentions a version of MS-DOS between 3.0 and 3.3 that can multitask. Can anyone else who was around during that era verify that there was a time that MS-DOS was being developed to multitask? Perhaps it's related to the reason DOS has concepts of critical regions?
Curious, I checked out Ralf Brown's list and found the correct DOS service (int 21h, ax=5D06h), but something struck me as interesting while reading the usage notes:
"Swapping the data area allows reentering DOS unless DOS is in a critical section delimited by INT 2A/AH=80h and INT 2A/AH=81h,82h."
Indeed, int 2Ah contains a DOS kernel service to enable/disable critical sections that does not appear to be typically used by applications. Not having access to my books about DOS internals anymore, this raises a few questions:
1. Is the DOS stack (assuming that's what STACKS in CONFIG.SYS is for) stored in the SDA?
2. What does DOS attempt to protect while inside a critical region? Is it up to the application to make sure it knows that DOS is currently in a critical region?
3. Why bother having a concept of critical regions in the DOS kernel if the application programmer is supposed to assume DOS is non-reentrant? I know multitasking libraries exist for DOS, but...
4. In the USENET post above, Ralf Brown mentions a version of MS-DOS between 3.0 and 3.3 that can multitask. Can anyone else who was around during that era verify that there was a time that MS-DOS was being developed to multitask? Perhaps it's related to the reason DOS has concepts of critical regions?