[sane-devel] pthreads for MacOSX (instead of child process)

Henning Meier-Geinitz henning@meier-geinitz.de
Mon, 3 Feb 2003 22:39:57 +0100


Hi,

On Mon, Feb 03, 2003 at 01:31:03AM +0100, Beat Birkhofer wrote:
> There's a problem with backends (plustek in my case) that use fork() 
> on MacOSX. Due to the IOKit it's impossible that two processes access 
> the USB at the same time.

Shouldn't the problem solved at the source, i.e. IOKit fixed or a
workaound written for that one? Isn't there a way to get the
priviledge for access for the second process?

Aren't there any other MacOS X programs/libs that suffer from this
problem?

> I solved the problem by replacing the child process by a pthread.

Be careful. The backends are written with processes in mind so they
may depend on the separated data structures.

General comment: don't use "//" comments, they are not supported by
every compiler.

> The problem: There are about 15 #ifdefs in plustek.c (quite ugly) and 
> I had to modify the Plustek_Scanner struct.

I don't like platform-dependent stuff in the backends, at least if
it's so intrusive.

> The solution for OS/2 (sanei_thread) didn't seem very useful for my
> problem because I had to apply changes to several functions.

I think sanei_tread is the right way. We are early in the development
phase so I don't see a problem to break the interface to sanei_thread
or invent a new one. In fact, it's used currently by just #defining
fork and other related functions. It seems to be more clear to really
use an explicit sanei_thread_start or similar. We just need to keep in
mind the requirements of (at least) OS/2, MacOSX and the standard
fork.

Bye,
  Henning