From: alistair@microsoft.com (Alistair Banks)
Subject: Re: Windows 3.1 & Processor Mode Swap
Date: 13 Sep 92 20:25:57 GMT
Organization: Microsoft Corporation

In article <Iegd38G00WB98APb1X@andrew.cmu.edu> ee0n+@andrew.cmu.edu (Eric James Ewanco) writes:
>Hi. I've been having a discussion with someone about WInodws over DOS
>
>Suppose a Win32 application mades a DOS call  First, does the trap go into
>Windows in Protected mode, or into DOS (in 21h)? 

Win32 Apps can't make Int21 calls under Win32s+Win3.1 or under Windows NT
so if one attempts to make such a call, the system GP faults that app

If you mean "What happens when a Win32 app, under Win3.1+Win32s, makes a
base i/o call?" the answer is that the call is executed by the
Win32s .dlls, and selectively executed within the Win32s VxDs, or "thunked"
back to the Windows system code - there are many places where the file i/o
calls can actually be fulfilled, some of which completely avoid ms-dos
code - the driver model (VxD) of Windows enhanced mode allows hooking
out of ms-dos code at various levels, including the 32-bit prot mode
fault caused by the Int XX or i/o instruction generated - Windows itself makes
use of every one of these levels for different i/o calls, and add-on
drivers make this even more complex - But at the end of the day, if the
original ms-dos code gets called, it'll be executed in
virtual x86 mode - if the ms-dos code accesses "physical" hardware, this
will be coordinated through traps and the physical access will
happen in VxDs in many cases, in some other cases the i/o ports are
not masked as protected, and the i/o will simply go ahead

>Hence, the big question, how many times does Windows switch between real and
>protected mode (protected and virtual 8086?) in a Win32 DOS call? Six is my
>guess.

As above, there's no general answer - from none, to very many, depending on the
call and the configuration of drivers

>Next question, related: what happens when a DOS program does a DOS call? 

The MS-Dos or BIOS Int XX call is executed in v86 mode, and faulting
occurs as and when appropriate as above

>Final question: DOS is still non-reentrant under Windows, right, so only one
>DOS call may be executing at any given time?

MS-Dos 1.0 -> 5.0 are largely non-reentrant, but Windows hooks out some
sections and executes the ms-dos functionality in its own code - this
"non-use" of "non-reentrant" code will only increase in the future!

>Basically I am trying to convince someone that Windows NT will be much more
>efficient and less crash-prone than Windows on top of DOS.  I am trying to show
>how awkward DOS compatibility makes Windows execution.

Windows NT's design-point is for security & robustness, Windows on MS-Dos's
design point is for compatibility & lower memory useage. I think you can
argue "awkwardness" and "efficiency" both ways in both versions. Windows NT
will more often "blow-away" the app in favour of protecting the system,
Windows on MS-Dos will more often let the app do "dirty" things to the system
in order to keep that app running, so "crash-prone" is relative to the
app or to the system - I'd argue that neither are crash-prone, both are
crash-resistant! -- Alistair
blow-away" the system

-- Alistair
Newsgroups: comp.os.ms-windows.programmer.win32