Mail Archives: djgpp/2006/08/21/11:37:09
> I'm trying to build either ftp://ftp.gnu.org/gnu/pth/pth-2.0.7.tar.gz or
> http://moss.csc.ncsu.edu/~mueller/ftp/pub/PART/pthreads.zip, but both
> fail to compile with serious errors. :-(
I doubt you could get pth compiled for DOS as it requires
either makecontext/getcontext/setcontext/swapcontext or
make[sig]setjmp/[sig]longjmp ... Though seeing as it is
not preemptive, you don't have to worry about functions
being reentrant, but you'd have to make liberal use of
pthread_yeild() or pthread_wait() in your code to allow
the context switches. It shouldn't be too difficult to
write some assembler for emulating makecontext/getcontext/
setcontext/swapcontext and 'port' GNU pth to DOS, infact I've
written make/set/get/swapcontext replacements for DOS before,
and there should be code out there you can reference (think
GNU's C library has some x86 assembler in there which
may be fairly portable for this purpose).
Regarding FSU pthreads, you may be able to get it to compile
as it has x86 assembler for the context switching, but it uses
setitimer() (I'm pretty sure) to generate alarms to do preemptive
task switching, which means all functions must be reentrant, I doubt
the C library in DJGPP is (primarily malloc/realloc/free/select and
other signal handlers are the concerns here)... If you don't know
what reentrant means, and the side-effects of it, do not even
research FSU pthreads, it will cause you nothing but headaches.
You may also want to look at clwp
(http://www.keesmoerman.nl/c_clwp_e.html) which is meant for
non-preemptive threading in DOS (non-preemptive in the same
way as GNU Pth). It just doesn't use pthread_* functions, it
has it's own conventions, but it does provide semaphores, etc as well.
-Brad
- Raw text -