Multithreading in DOS

DOS specific questions.
monochromator
Posts: 42
Joined: Mar 05, 2013 5:37

Multithreading in DOS

Post by monochromator »

I have added supporting of multithreading in FreeBASIC For DOS.
Support of multithreading uses the DJGPP port of PTHREAD 2.07 library.
Attached archive contains FreeBASIC runtime library with multithreading (libfbmt.a),
runtime library without multithreading (libfb.a), two simple threading examples
and all source files of runtime library, which was added or changed.

Instruction on installation:

1. Replace LIBC.A, LIBFB.A and LIBFBMT.A from LIB\DOS with corresponding files from archive.
2. Try to compile and execute two examples - THREADS.BAS and THREADS2.BAS
THREADS program:
fbc -mt THREADS.BAS
THREADS2 program:
fbc -mt THREADS2.bas

Directory "SRC" contains source files, which was added or changed.
First of all, "makefile" was changed, which is located in the root of source code tree.
Files "thread_ctx.c" and "fb_private_thread.h" is situated in directory SRC\RTLIB.
At last, files "thread_core.c", "thread_cond.c" and "thread_mutex.c" was added to SRC\RTLIB\DOS directory.

New runtime library supports all standart FreeBASIC threading subroutines and functions except ThreadCall.
Support of ThreadCall is not released yet because there is no DJGPP port of LibFfi library.
In near future l shall try to compile LibFfi for DOS and add ThreadCall support.

I would like to ask the forum users who are interested in the development of FreeBASIC for DOS,
to participate in the testing and report any bugs here.

Download link: http://tempfile.ru/file/2878250.
Last edited by monochromator on Jun 12, 2013 13:57, edited 1 time in total.
angros47
Posts: 2323
Joined: Jun 21, 2005 19:04

Re: Multithreading in DOS

Post by angros47 »

In your file, I can't find THREADS.BAS and THREADS2.BAS.

Anyway... dynamic linking, multithreading.... you are going to port SEAL (or IkonGUI, or something similar) to FreeBasic, I guess.

Years ago, I ported Windoze (an old, but very good GUI originally written for QBASIC) to FreeBasic; with dynamic linking and threads, writing a pseudo-OS (an OS running over DOS, like windows 95) in Freebasic would become a real option.
monochromator
Posts: 42
Joined: Mar 05, 2013 5:37

Re: Multithreading in DOS

Post by monochromator »

There is new version with tests and corrections some bugs.
http://tempfile.ru/file/2878496
angros47
Posts: 2323
Joined: Jun 21, 2005 19:04

Re: Multithreading in DOS

Post by angros47 »

If I compile without "-mt", it build an executable, that crash (exiting due to signal SIGILL)

DosBox on linux, using CCSDPMI.

Maybe I need another extender?
DOS386
Posts: 798
Joined: Jul 02, 2005 20:55

Re: Multithreading in DOS

Post by DOS386 »

> There is new version with tests and corrections some bugs
> http://tempfile.ru/file/2878496

Interesting ... downloaded (2 MiB !!!) ... not yet tested.
angros47 wrote:Anyway... dynamic linking, multithreading.... you are going to port SEAL (or IkonGUI, or something similar) to FreeBasic
Multithreading <> GUI ;-) Maybe port 7-ZIP instead ?
monochromator
Posts: 42
Joined: Mar 05, 2013 5:37

Re: Multithreading in DOS

Post by monochromator »

To angros47:
The cause is not in an extender. The matter is that the libraries Pthread and Watt32 used for the organization of a multithreading, are compiled for the processor i686 and contain some instructions specific to Pentium II+ processors. DOSBOX isn't able to execute them therefore there is an exception "Invalid OpCode" (In this case it is the conditional move command CMOVE).
It is necessary to recompile libraries that I while can't make.
Therefore while multithreading work in DOSBOX is impossible.
As far as I understand, you use Linux. Can you check the discussed subject not in DOSBOX, but in DOSEMU?
angros47
Posts: 2323
Joined: Jun 21, 2005 19:04

Re: Multithreading in DOS

Post by angros47 »

Ok: I tried it in QEMU, with MS-Dos 6.20 and HX extender, it works.

Thank you!
rugxulo
Posts: 219
Joined: Jun 30, 2006 5:31
Location: Usono (aka, USA)
Contact:

Re: Multithreading in DOS

Post by rugxulo »

monochromator wrote:To angros47:
The cause is not in an extender. The matter is that the libraries Pthread and Watt32 used for the organization of a multithreading, are compiled for the processor i686 and contain some instructions specific to Pentium II+ processors. DOSBOX isn't able to execute them therefore there is an exception "Invalid OpCode" (In this case it is the conditional move command CMOVE).
It is necessary to recompile libraries that I while can't make.
Therefore while multithreading work in DOSBOX is impossible.
As far as I understand, you use Linux. Can you check the discussed subject not in DOSBOX, but in DOSEMU?
IIRC, /beta/pth207b.zip (and some other stuff, e.g. /beta/bnu217b.zip) was accidentally compiled for 686+ (CMOVxx). You can use instead /current/pth207b.zip (and/or recompile from source, which didn't work for me back in the day, but I didn't stick with it) for 386+. Though this port is abandoned and not supported, at least not for DJGPP. And I'm honestly not sure it works properly under FreeDOS (perhaps some rare bug, dunno).

DOSBox is "only for games", so it's intentionally lacking a lot of stuff (and its built-in DOS isn't a real one like DOSEMU uses). It can optionally emulate a 586, at best, but by default I think it's only a "fast" 486 DX2 (with CPUID).

There is an alternate thread library called FSU Pthreads. It was resurrected in recent years (thanks to Khusraw) to compile for DJGPP again. It doesn't need a socket library (libsocket nor Watt-32). It is used in latest (buggy but mostly usable) unofficial DJGPP compiles of p7zip (9.13, 9.20.1).
Cpcdos
Posts: 207
Joined: Mar 06, 2013 13:52
Location: France - LYON 69003
Contact:

Re: Multithreading in DOS

Post by Cpcdos »

This file is not found :(

«
Файл удален.
Более подробный ответ Вы можете найти в разделе
Правила
»
Cpcdos
Posts: 207
Joined: Mar 06, 2013 13:52
Location: France - LYON 69003
Contact:

Re: Multithreading in DOS

Post by Cpcdos »

Re !
coderJeff
Site Admin
Posts: 4326
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Multithreading in DOS

Post by coderJeff »

I know this is an old thread, but I think it is the one referenced from angros47 in Pull Request #44.

This feature works pretty well? Any special differences that need to be noted in the documentation? Most of the threading pages just mention that threading is not available on DOS.
angros47
Posts: 2323
Joined: Jun 21, 2005 19:04

Re: Multithreading in DOS

Post by angros47 »

The feature works, although I can't guarantee its reliability.
coderJeff
Site Admin
Posts: 4326
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Multithreading in DOS

Post by coderJeff »

If you remember forum member DOS386, he was most critical of the dos implementation, but also very understanding of the limitations or differences provided that it was documented. I don't use the DOS build of fbc for anything. If those using this feature could help update the documentation, would be very helpful to the project and all fbc -target dos users.
fxm
Moderator
Posts: 12107
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Multithreading in DOS

Post by fxm »

coderJeff wrote:I don't use the DOS build of fbc for anything.
Neither do I.
vb4fb20XX
Posts: 2
Joined: Mar 26, 2018 20:03

Re: Multithreading in DOS

Post by vb4fb20XX »

fxm wrote:
coderJeff wrote:I don't use the DOS build of fbc for anything.
Neither do I.
I may be new here -but I'm using it.

Howdy, folks. Nice to meet you all. :)
Post Reply