flat assembler
Message board for the users of flat assembler.

Index > DOS > Multithreading in DOS : the truth is out :-(

Goto page Previous  1, 2

Is multithreading impossible in DOS ?
YES
13%
 13%  [ 2 ]
What is DOS ???
6%
 6%  [ 1 ]
No idea, do not care as long as __my__ 16 cores per 64-bit do work
13%
 13%  [ 2 ]
It is possible ... see your code, PTHREADS , HX , ... , ... , ...
66%
 66%  [ 10 ]
Total Votes : 15

Author
Thread Post new topic Reply to topic
sakeniwefu



Joined: 23 Mar 2008
Posts: 29
sakeniwefu
I did not say it could be made general, or optimal, if you cannot move the stack around, or your CPU has an internal stack(and a single register!), that's a big limitation. Sad

Quote:

# Stack:

* The hardware call stack is so small that program structure must often be flattened
* The hardware call stack is not addressable, so pre-emptive task switching cannot be implemented
* A software-implemented stack cannot be implemented efficiently, so it is difficult to generate reentrant code and support local variables


So I see your problems, but it doesn't appear to be impossible, just impractical for general cases.

It is not usable for anything, but I would believe something like this would be possible in any processor?

start: RT1(1)
RT2(1)
RT1(2)
RT3(1)
...
jmp start

Each routine would store the data needed to stay working in known memory locations. As long as the routines didn't need a growing stack, they would be safe. Of course, you wouldn't be able to switch priorities at runtime. Correct me if I am wrong.

_________________
Warning: C code found, deleting.
Post 23 Mar 2008, 12:40
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16847
Location: In your JS exploiting you and your system
revolution
Okay, but that stretches the meaning of multi-threading to the limits. Previously I would not have thought of that as any sort of threading.
Post 23 Mar 2008, 13:32
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2468
Location: Bucharest, Romania
Borsuc
If you have a memory, and you have pointers, you can build a stack -- what's so special about the hardware stack (besides obvious speed or size optimizations)?

so it isn't impossible at all
Post 23 Mar 2008, 13:40
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16847
Location: In your JS exploiting you and your system
revolution
The_Grey_Beast wrote:
If you have a memory, and you have pointers, you can build a stack -- what's so special about the hardware stack (besides obvious speed or size optimizations)?

so it isn't impossible at all
Hehe, sure we could simply make a VM and run any arbitrary code. But with the smaller MCU's it might be tricky to squeeze in a VM and another OS inside the VM all within 512 program words and 64 bytes of RAM. Rolling Eyes
Post 23 Mar 2008, 13:45
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
DOS386 wrote:
rugxulo wrote:
yes DOS can multitask (DesqView, DR-DOS, Win 3.x)


Not DOS Wink


Eh? How is DR-DOS not DOS? Even DesqView should count as it's just a program. Win 3.x? Okay, maybe not pure DOS, but still ....

DOS386 wrote:

Quote:
nice job, but why is the example so, er, useless? Creating a 40 MB file?? I mean, I assume you have a reason, but still


1. Examples are usually "useless"
2. Creating a huge file ... to get time for showing the progress indicator Wink
3. Should I create an example of progress indicator applied to a sophisticated compiler, compressor, brutal-forcer instead ? An "example" with several 10'000's lines ? Shocked


1. I meant that creating 40 MB file isn't as useful as your other examples.
2. Yes, I see that. Smile
3. No, it doesn't have to be that complex. You could integrate the progress thingy inside something small like xWCopy perhaps??
Post 24 Mar 2008, 03:16
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386
> Eh?

There is no "eh". Note where I cut the quote. Dr-DOS is DOS,
but I still don't like it's DREMMM386 Sad

> Win 3.x? Okay, maybe

Very sure not Shocked

> 3. No, it doesn't have to be that complex. You could integrate
> the progress thingy inside something small like XWCopy perhaps ?

YES. FYI, I have been working on porting it to FASM that time.
Did you do apply any changes except porting to NASM ?


Last edited by DOS386 on 24 Mar 2008, 08:41; edited 1 time in total
Post 24 Mar 2008, 08:22
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386
> Also, why do you put "define pope pop"? Why not just use "pop reg" and
> replace "pope" with "pop" in your code?

But then I would have to "define pus push" Wink

> Any system that supports interrupts can theoretically do multitasking,
> just save state and jump to another thread or task when a certain interrupt occurs.

Exactly.

I've seen many attempts to do MTSK, but none of them was really good. Either do
it well, or don't do it at all Idea
Post 24 Mar 2008, 08:38
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
DOS386 wrote:

> 3. No, it doesn't have to be that complex. You could integrate
> the progress thingy inside something small like XWCopy perhaps ?

YES. FYI, I have been working on porting it to FASM that time.
Did you do apply any changes except porting to NASM ?


Well, it originally was 386+ and yet used very very very little 386-specific instructions that I decided (with help of Eric Auer) to convert it to 8086. In fact, I had previously converted it to FASM, but for this version I chose NASM only because there's an old 16-bit NASM still available on SourceForge, and I figured some people (ahem, Trixter/8088 Corruption dude, who I also emailed) might want to tweak it.

P.S. I actually used MCD's ONLY8086.INC in my 0.7 hack, but I had to manually work around some conditional jumps that were > 128 bytes away. However, then I discovered revolution's compatibility macros. And also, NASM "-O3" does the same thing. So, if it weren't for trying to be nice to potential 8086 developers, I would've definitely used FASM again. (For revolution's macros, you have to use ".086" explicitly for the jumps to be automagically tweaked.)
Post 24 Mar 2008, 20:44
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.