X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Message-ID: <44E9CD2C.9080904@mainstreetsoftworks.com> Date: Mon, 21 Aug 2006 11:11:40 -0400 From: Brad House User-Agent: Thunderbird 1.5.0.5 (X11/20060803) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: How to build threading libraries? References: <44e9c17f$0$10150$9b4e6d93 AT newsspool2 DOT arcor-online DOT net> In-Reply-To: <44e9c17f$0$10150$9b4e6d93@newsspool2.arcor-online.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com > 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