Qbasicnews.com

Full Version: Protected mode question...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Does a FreeBASIC-compiled program switch into protected mode itself, or does it use the DPMI to do it?

Either way, I would like to switch into protected mode myself. How would I do this in FB (or not in FB) ?
I don't think it's possible, the runtime library is the DjGPP one, that depends on DPMI services to invoke DOS and so on.
To use FB DOS (or a program which has been compiled with it) in pure DOS mode (no Windows), you must place CWSDPMI.EXE in the program directory, or in a directory which is accessible from the PATH.

When the program is launched, it will call CWSDPMI.EXE to switch to protected mode (if I understand correctly...)

As said in the documentation, the CWSDPMI package is available at:

http://clio.rice.edu/cwsdpmi/csdpmi5b.zip

Perhaps it could be useful to add this package to the FB DOS distribution?
CWSDPMI is just generic DPMI host server, I think that any DPMI server can be used. The following thoughts are just guesses: CWSDPMI is not PMODE extender. PMODE setup is handled propably by calling DPMI interrupts from DjGPP runtime library which is included into FB exe as part of FB runtime library Smile. Thus looking some info about PMODE setup in DjGPP might help you. However may I ask why do you want to setup PMODE yourself?
Generally just to play with; although I thought it would be amazingly cool if I could get two FBDOS programs running simultaneously. However, I highly doubt I can accomplish this. :-P (Is this even possible?)

No big deal, though. Maybe one of these days...
Threads in DOS would be quite difficult to add, as our little outdated OS isn't re-entrant. There is a version of the Pthreads lib that comes with a "djgpp" dir, but i never saw any app using it, nor i ever tried to get it to build - it isn't updated since a decade ago.

The DPMI host can be anyone, the only server loaded externally at runtime that i know is CWS, and it's shown in the readme file where to download it. The DJGPP loader uses the DPMI services to "switch" to pmode, the FB rtlib does not have to mess with that.
May I ask what kind of memory schema FB exactly uses? One big 4GB read only code segment loaded to CS, plus one big 4GB shared writable data segment loaded DS,GS,ES etc?

You can do simple multithereading by reprogramming timer interrupt ISR, however you can not call DOS and you must implement all synchronization primitives yourlself. You can even try to call DOS and avoid jumping into it by using simple semaphore flag when busy. Maybe there is some other threading lib availible for DjGPP too, but I don't think you will be able to run two classic FB programs at same time in pure DOS. Hovever you can run two functions simultaneously using that timer reprogramming (quite advanced asm coding, but not impossible), however I always failed Smile in that.