[fpc-devel] Multithreading under DOS
Nikolay Nikolov
nickysn at users.sourceforge.net
Thu Sep 26 19:44:31 CEST 2013
On 09/25/2013 08:13 PM, Tomas Hajny wrote:
>
> Anyway, interesting thread. ;-) Still, the overall goal (or set of goals)
> is not clear for me from the limited context included:
>
Ok, here's my point:
Since the FPC RTL offers pluggable thread manager support, we can offer
multiple implementations. Just like Linux has cthreads, we can have
several threading options.
1) One that requires DR-DOS and its multitasker. This one would be the
easiest to implement for both i8086-msdos and i386-go32v2 and may be a
good enough reason enough not to disable the threading support for DOS
(i.e. to not treat threadvar as regular var).
2) Cooperative multithreading, which requires each thread to call .yield
periodically. This can also be implemented in both i8086-msdos and
i386-go32v2 and should also be easy and compatible.
3) Preemptive multitasking, implemented in the RTL. This will be the
hardest one to implement, but is certainly possible at least in
i8086-msdos. For i386-go32v2 I'm not so sure. As I said, I believe it
would require extensions to the DPMI host. This can be done by extending
cwsdpmi or some other open source DPMI host and I guess it would be hard
to stabilize, but it's still quite possible. And, if done correctly,
would work under regular DOS under real mode or even a VCPI host like
emm386.exe, but will certainly not work under a windows dos prompt or
while some other dos extender/dpmi host/multitasker is used.
Ideally, all 3 can be implemented, but any of the three would be an
improvement to the current situation under DOS, which is no threading at
all. And none of the 3 would be good enough to be put as the default
thread manager, because each one has some drawbacks, that have to be
considered carefully by the programmer, so it should be left to the
programmer to choose. The drawbacks for each one are the following:
1) requirement of DR-DOS
2) the need to add calls to .yield
3) stability and compatibility issues with certain dos boxes (including
the windows command prompt) and perhaps drivers
Nikolay
More information about the fpc-devel
mailing list