[News] POSIX threads ported to 68k Amiga | ANN.lu |
Posted on 28-Jan-2004 22:27 GMT by whoosh | 28 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 |
POSIX threads ported to 68k Amiga : Comment 10 of 28 | ANN.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! |
|
List of all comments to this article (continued) |
|
- User Menu
-
- About ANN archives
- The ANN archives is powered by #AmigaZeux. It was updated daily (news last: 22-Oct-2004; comments last: 18-May-2005).
ANN.lu was created, previously owned and maintained by Christian Kemp, www.ckemp.com.
- Contribute
- Not possible at this time!
- Search ANN archives
- Advanced search
- Hosting
- ANN.lu was hosted by Dreamhost. Sign up through this link, mention "ckemp" as referrer and he will get a 10% commission on any account you purchase.
Please show your appreciation for any past, present and future work on ANN.lu by making a contribution via PayPal.
|