Why does the application need to be in the same V86 space as DOS? Then the application could have a full 640k (or more).
Might have to page some memory areas the same between the two, but EMM386 enables paging anyway.
In case of such overlapping memory how would you tell which memory application is trying to access - its own or DOS's (given a real mode segment
ffset addresses)?
It is possible to get more memory using other tricks. For example nobody really requires 09FFFFh to be the top of the memory. If your application is not using EGA/VGA frame buffer at 0A0000h, you could extend the memory to 0B0000h or even to 0B8000h. Also there is UMB and EMS memory which can be emulated by EMM386.
And if its not too difficult why can't we have more than 1 V86 application, effectively multitasking DOS.
In this case the applications are RM, But why can't we have PM tasks as well?
That's what Windows 3.1+ and other more modern (than DOS) OSes do. They can run multiple DOS applications using VM86 boxes, and some protected mode applications at the same time.
Now if you want to do something simpler (say just the ability to run multiple DOS applications without all the Windows overhead), you'll really need to visualize all of I/O at all possible levels (MS-DOS, BIOS, direct access to I/O ports, DMAC, interrupt controller, and such).
There are quite a few problems with that:
- DOS by itself is not intended to be multitasking OS. It is not reenterant - which can be resolved by monitoring DOS functions, and making sure it is being called only by one application at the time. But then some DOS functions might block (making all applications wait). Simply running multiple DOS copies is not a solution either (at least not if they share same disks).
- Same situation (even worse) with BIOS.
- Finally you need to think what to do with I/O. In some cases it might be OK to simply pass I/O to hardware, but in most cases you'll want to understand what is that the application is trying to do, and make sure it doesn't conflict with other applications, or will not cause system crash. Just to give an example - an application can try to change the interval of the timer interrupt IRQ0 (which games frequently do). But there are other things that use the same interrupt - e.g. BIOS uses it for clock and delays. So if you don't take case of this, it will potentially break things for other applications. And it is just a simple example...