[fpc-devel] Threads and alot of crap
Ales Katona
ales at chello.sk
Mon Oct 9 22:04:04 CEST 2006
I've had the "honor" of looking at current TThread/pthreads/cthreads
implementation in unix (FreeBSD to be precise) and found it extremely
bad.
Not to criticize, I'm here to ask for permission/toughts on adding a few
standard methods to TThreadManager.
I would like to add semaphore functions to it, to be able to use them in
Classes/TThread implementation. The reason for this is, that Classes is
compiled BEFORE pthreads and as such I cannot use pthreads directly (and
shouldn't for linking issues to libc) to implement threading in TThread.
I see basicly 3 approaches:
1. add semaphore/mutex functions to TThreadManager record
2. add a new "semaphores" record
3. move the TThread - threading specific functions out of tthread and
into a "TThreadTThreadManager" kind of thing. Eg: "start thread with
this callback" and such which are currently used in tthread.inc
Not sure which one is best..
Another thing.
I noticed that FreeBSD has 3 implementations of pthreads.
libpthread, Libc_r (reentrant) and "libthr" (1:1 kernel threads).
Currently fpc does some sort of automagical "descision" between libc and
libpthread. I think users should be able to specify this somehow.
I've cleaned up unices I know off old {$IFDEF Linux} but I also want to
add proper threading and remove the idiotic pipe/semaphore hack.
Ales
More information about the fpc-devel
mailing list