Multithreading in DOS

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

Multithreading in DOS

Postby monochromator » Jun 12, 2013 7:19

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: 1315
Joined: Jun 21, 2005 19:04

Re: Multithreading in DOS

Postby angros47 » Jun 12, 2013 13:45

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

Postby monochromator » Jun 13, 2013 7:52

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

Re: Multithreading in DOS

Postby angros47 » Jun 14, 2013 23:10

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

Postby DOS386 » Jun 15, 2013 6:18

> 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

Postby monochromator » Jun 15, 2013 10:35

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: 1315
Joined: Jun 21, 2005 19:04

Re: Multithreading in DOS

Postby angros47 » Jun 16, 2013 18:12

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

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

Re: Multithreading in DOS

Postby rugxulo » Jun 24, 2013 19:12

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: 196
Joined: Mar 06, 2013 13:52
Location: France - LYON 69003
Contact:

Re: Multithreading in DOS

Postby Cpcdos » Aug 15, 2013 17:22

This file is not found :(

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

Re: Multithreading in DOS

Postby Cpcdos » Nov 15, 2013 13:47

Re !

Return to “DOS”

Who is online

Users browsing this forum: No registered users and 1 guest