[sane-devel] pthread support and MacOS X
Tue, 7 Oct 2003 10:08:27 +0200
I've done some more changes to the sanei_thread library:
- supports either fork or pthread stuff
sanei_thread_begin --> uses fork and starts the function in child conte=
or uses pthread_create
sanei_thread_waitpid --> are mapped to kill/waitpid or pthread_kill/
The goal is to allow the usage of sanei_thread in any case. Two additiona=
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=
between the two models
I've also updated the tests in the configure script. You'll find the swit=
--enable-fork-process, with is used to override the default settings for
pthread/fork usage. The default is: use pthread on Darwin (if available),=
The migration to this sanei_thread stuff is not complete now, but if nobo=
has objections on that, I'd like to adapt the test-backend, to show the u=
On Sonntag, 5. Oktober 2003 23:54, Henning Meier-Geinitz wrote:
> 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=
> > the Plustek backend, so that it will use threading instead of forking=
> > 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.