23-Apr-2024 20:24 GMT.
UNDER CONSTRUCTION
[News] POSIX threads ported to 68k AmigaANN.lu
Posted on 28-Jan-2004 22:27 GMT by whoosh28 comments
View flat
View list
straight clean port of Ralf S Engelschall's pth-1.4.0 a non pre-emptive implementation of POSIX threads to 68k Amiga. This is 2 gcc linker libraries to enable porting + writing of threaded programs to 68k Amiga. http://www.whoosh777.pwp.blueyonder.co.uk/pthreads.html To see a threaded program run on 68k Amiga download and run "the 5 philosophers":

http://www.whoosh777.pwp.blueyonder.co.uk/test_philo (requires just ixemul.library),

:this example program uses libpth.a,

The port itself is 2 gcc linker libraries: libpthread.a and libpth.a,

Last December I ported rpm4.0 with databases disconnected as database support required libpthread.a . So now I should be able to generate a full port of rpm4.0 (or higher) to 68k,

(its not at the top of my to-do list)

This port took only one day to do, an attempt at a totally different pre-emptive implementation of libpthread.a took well over a week before I gave up.

Anyway the consequence of this port of pth-1.4.0 is that it will enable porting of threaded programs. Probably noixemul progs will also be ok.

Even though it is only 1 days work I thought it was worth an announce as people always say the classic Amiga cant thread, well it can thread!

The most difficult thing was locating pth-1.4.0 as I didnt know it existed till I found it, I was only searching for libpthread.a

No idea if the example program will run on PPC or Amithlon, email me if you try it on such.

The advantage of being non-pre-emptive is that it is much more portable and clean. And if it implements POSIX threading (nightmare specification) it implements POSIX threading! (non-pre-emption notwithstanding) The source + necessary fixes to quite bugged configure are on http://www.whoosh777.pwp.blueyonder.co.uk/pthreads.html

List of all comments to this article
Sorted by date, most recent at bottom
Comment 1Golem29-Jan-2004 00:47 GMT
Comment 2Anonymous29-Jan-2004 08:28 GMT
Comment 3Anonymous29-Jan-2004 08:35 GMT
Comment 4Kjetil29-Jan-2004 10:44 GMT
Comment 5Thematic29-Jan-2004 11:50 GMT
Comment 6whoosh29-Jan-2004 16:53 GMT
Comment 7whoosh29-Jan-2004 18:39 GMT
Comment 8Fabio AlemagnaRegistered user29-Jan-2004 19:51 GMT
Comment 9MarkTime29-Jan-2004 21:49 GMT
POSIX threads ported to 68k Amiga : Comment 10 of 28ANN.lu
Posted by whoosh on 30-Jan-2004 01:23 GMT
In reply to Comment 8 (Fabio Alemagna):
I said:


>> Anyway its too late now, I have ported a fully


>> functioning version, I would never dream of putting my port in the


>> alpha directory,


Fabio Alemagna said:


>Not to push you down, but correct me if I'm wrong:


>"ported" here simply means "recompiled", doesn't it?


Not my port, recompile is not enough,
my port==configure+recompile+binary runs correctly,
when I say binary runs correctly I mean that the 8 relevant example
test programs linked with the binary library run correctly.
You can download and try on 68k 7 of those example programs:


threaded_68kprograms.lha from the above website.


With my port of Pth all the example test programs run correctly
thus not only is the binary generated ie successful recompile
but also said binary runs correctly.


Contrast with pthreads-1_60_beta6 which I have recompiled + generated binaries
but when you run, it functions correctly but crashes on exit if you
use any of their replacement stdio functions (printf() and write()
in particular),


Thus my pthreads-1_60_beta6 can join their one in the alpha directory,
a port which crashes or otherwise malfunctions is fairly useless.


With Pth 1.4.0 in particular, the configure script (168774 byte
unix shell script, not as big as rpm4.2 which has a 732365 byte script
but big nonetheless) crashes at many places. Debugging it is
going to take weeks and a thorough command of the unix shell.
So you cannot even configure the port,
the problem being that the script cannot cope with the
specific problems of the GG Amiga environment, I use an
untampered with Geek environment. The docs claim its tested on AmigaOS,
so how come the script crashes again and again and again on AmigaOS.


Most of the work of the port is in engineering the configure
script to complete mainly by using devious trickery.


Example of a thing the configure script cannot cope with is to determine
direction of stack growth. So if you get that wrong the port is
going to nose dive into the abyss by setting the thread stack pointers
to the wrong end! One problem is the configure script is making
all sorts of assumptions which sadly dont hold on AmigaOS GG.


A specific technical bug in the configure script is it
determines if SYS_read is defined thus:


#include <sys/syscall.h>


#ifdef SYS_read


yes SYS_read is defined!


#endif


sadly this trick fails on AmigaOS because on AmigaOS SYS_read is defined
in sys/syscall.def via the above #include,
but the above trick tells you it isnt defined, ie the above trick is bugged.
I think the trick fails because for AmigaOS SYS_read is defined by
sys/syscall.def via an enum, unfortunately things defined via enum
fail the #ifdef test, an annoying subtlety of c. I think #ifdef is only
true in c for things defined via #define, things defined by other means
such as enum's and eg "int x;" fail the #ifdef test.


>Pth has always supported AmigaOS,


it claims to support AmigaOS, and after a lot of brute force
fixing of the configure script it does, but not AS-IS.


And if it supports AmigaOS why does the configure script crash
in so many places on AmigaOS?? Their documentation is not being
entirely truthful. The problems are entirely at the configure stage,


>all you had to do was grab the sources and compile.


If only! before you compile you have to configure and
the configure (could take an hour to execute on my 68030 setup)
crashes repeatedly. Eg the configure attempts to extract all sorts of
info such as obscure system specific types using sed,
and evidently it does this wrongly.


Before you configure there is no makefile, the configure
generates right at the very end the makefiles so if the
configure crashes you have no makefiles so you cannot compile.


So by hook or by crook you have to get the configure script to complete,
which I managed. I begun the evening before the announce and the next
evening the automatically executed test procedure successfully completed
(test_std) followed by an automatically generated "Good luck!" message!


You cannot simply do eg "gcc #?.c", its a bit more complicated than that!


With pthreads-1_60_beta6 (and all other versions of pthreads),
things are more tricky because when you
configure it tells you that amigaOS is unsupported, bye!


:So the first challenge is to get around this, you also need to supply
a handful of system specific source files, with scant info on how
to generate these. Anyway as far as I can see I have supplied the
correct system specific files, but the example test progs all
crash on exit. If I dont use their replacement stdio functions
but instead just directly use ixemul then there is no crash on exit
but also the POSIX specification of libpthread.a is flouted so
the example progs generate error messages (but dont crash).


So I can currently generate pre-emptive threading,
its just not POSIX threading though!
Jump...
#11 Sigbjørn Skjæret #15 Anonymous
TopPrevious commentNext commentbottom
List of all comments to this article (continued)
Comment 11Sigbjørn Skjæret30-Jan-2004 01:49 GMT
Comment 12Oppressor30-Jan-2004 01:56 GMT
Comment 13Golem30-Jan-2004 04:45 GMT
Comment 14Anonymous30-Jan-2004 09:10 GMT
Comment 15Anonymous30-Jan-2004 12:47 GMT
Comment 16whoosh30-Jan-2004 21:23 GMT
Comment 17Sigbjørn Skjæret31-Jan-2004 00:05 GMT
Comment 18Oppressor31-Jan-2004 03:56 GMT
Comment 19Kolbjørn Barmen31-Jan-2004 16:49 GMT
Comment 20whoosh01-Feb-2004 20:33 GMT
Comment 21Sigbjørn Skjæret01-Feb-2004 23:30 GMT
Comment 22whoosh02-Feb-2004 20:18 GMT
Comment 23Sigbjørn Skjæret02-Feb-2004 20:39 GMT
Comment 24whoosh02-Feb-2004 20:59 GMT
Comment 25whoosh02-Feb-2004 21:32 GMT
Comment 26whoosh04-Feb-2004 18:08 GMT
Comment 27whoosh04-Feb-2004 20:50 GMT
Comment 28whoosh05-Feb-2004 17:36 GMT
Back to Top