Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is threading possible in MS-DOS?
#1
Besides threading, is any form of multitasking possible under MS-DOS? E.g., could I write a threading/multitasking system in FreeBASIC, which runs in 32-bit protected mode, and run it on any MS-DOS machine?

If possible, how would I go about doing something like this? It has something to do with stepping through the possible tasks, and saving the registers for each task and then reloading them when the task switches back into the main focus. Or something like that. But I don't have a clue how to do that.

Also, on a larger scale, if this were possible, how would I go about multitasking two executable (MS-DOS .exe) files? How would these processes communicate?

Any help, or any pointers towards documents or tutorials for anything relevant to this kind of stuff would be much appreciated.

Thanks. :-D
color=blue]subxero - admin at this place.[/color]
Reply
#2
You cant do multitasking in DOS.

You can create new interrupts, and thats basically it..

Or you could make your own "multitasking" by quickly switching between running processes... (just like windows does)
Reply
#3
That's what I'm talking about: creating my own system of multitasking. I'm not asking if it's already usable, but whether or not it's possible to create.

How would I create this using plain ol' executable files as the multitaskees?
color=blue]subxero - admin at this place.[/color]
Reply
#4
Well.. first, you load the EXEs into memory (preferably, or use a HD swap/paging file..)

Then strip their header info, (after you've read it ofcourse)


After that you execute one instruction of an EXE, then swap all registers (store them in mem)

Execute one instruction of the next EXE, swap again..

Swap back to the first set of registers, execute the next instruction of the first EXE.. swap regs. to mem

Swap to the second set of registers, execute next instruction of the second EXE...


And so on, so forth...

It sounds easy, but it's really hard, and amazingly annoying to code... Tongue
Reply
#5
Z!re that sounds sweet and as you said it is really hard.
More than it is teddy job because your system would be able to run only very simple programms Cry
url=http://zerodivide.h15.ru/cyclone.html]Cyclone v2.5.2 GUI For QBasic 4.5/7.1[/url]
Explorer For DOS
Reply
#6
Generally you don't execute a single instruction as that would slow the system down horribly.

Instead, you give threads "slices" of "time shares" based on priorities.

ie:
real = 8:1
high = 4:1
normal = 1:1
low = 1:4
suspended = 0

So, if there are 5 threads running, one at realtime and the rest at normal, then the total time shares are 11 (8 +1 +1 +1), the realtime thread would be allowed to run for 8/11 of a second, then the rest would be able to run for 1/11 and the list starts again.

This way each thread can run for a bit without interruption and actually get things done. Of course, the thread can give-up the rest of it's time slice and other threads can run for longer. In this way, any "idle" time can be used by the thread manager to do maintainance or just let the CPU cool down.
Life is like a box of chocolates', hrm, WTF, no it isn't, more like, 'life is like a steaming pile of horse crap.'
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)