Hi list, I've done some more changes to the sanei_thread library: - supports either fork or pthread stuff This means: sanei_thread_begin --> uses fork and starts the function in child conte= xt or uses pthread_create sanei_thread_kill and sanei_thread_waitpid --> are mapped to kill/waitpid or pthread_kill/ pthread_join
The goal is to allow the usage of sanei_thread in any case. Two additiona= l functions are sanei_thread_init --> mainly to initialize the debug interface sanei_thread_is_forked --> to distinguish in the backend if we're forked or not, as some diffs in the backend might re= main between the two models I've also updated the tests in the configure script. You'll find the swit= ch --enable-fork-process, with is used to override the default settings for pthread/fork usage. The default is: use pthread on Darwin (if available),= else use fork. The migration to this sanei_thread stuff is not complete now, but if nobo= dy has objections on that, I'd like to adapt the test-backend, to show the u= sage. Any comments? Ciao, Gerhard On Sonntag, 5. Oktober 2003 23:54, Henning Meier-Geinitz wrote: > Hi, > > On Sun, Oct 05, 2003 at 06:16:12PM +0200, Jaeger, Gerhard wrote: > > I've currently added pthread support to the sanei_thread lib and chan= ged > > the Plustek backend, so that it will use threading instead of forking= on > > MacOS X. Could somebody please test this? > > Also the detection of pthreads is not correct, please test also... > > Just some quick comments, I'll test more during the next few days: > > - I think it's good to have support for different types of fork/thread > whatever. However, I'd like to have that completely in sanei_thread > (or wherever). So I'd call sanei_thread_begin in my backend and > don't care if it expands to pthreads, OS/2 threads or fork. This > means some limitations (e.g. only one parameter for OS/2?) and we > have to check that the reader processes work with both threads and > processes. Otherwise we must have #ifdefs for 3 platforms in our > backends as both OS/2 and MacOS need special care now. MacOSX needs > sanei_thread_whatever, OS/2 needs fork() and a encapsulated > reader_process and everything else needs fork() only. > > - The docu in include/sane/sanei_thread.h should be updated (but only > when we are sure if we keep the current implementation) > > - SANE_CHECK_PTHREAD must go into acinclude.m4. aclocal.m4 is > generated automatically from acinclude.m4 when you run "aclocal". > (After that run autoheader and autoconf). Otherwise it would be > deleted by the next run of aclocal. > > - Linking fails on Free- and OpenBSD. I had only a quick look > but I think it's because they don't have a libpthread but pthread.h. > Before adding -lpthread you should check if the lib is available > (not only a header). Maybe you should check for the header first and > then if one of the pthread functions is available (in libc). If it > isn't, try if it's available in libpthread and link that lib. > > - I'm not sure if we should use threads by default (link to > libpthread) or only on MacOS X. Maybe that should be a configure > option (--enable-pthreads: default yes on MAcOS, no everwhere else)? > > There are other compilation/linking problems on other platforms but > they may not be related to pthread. I'll look later. > > Bye, > Henning