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

abel deuring a.deuring at satzbau-gmbh.de
Tue Feb 4 18:13:17 GMT 2003


Henning Meier-Geinitz wrote:
> 
> 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?

Sounds reasonable. Out of curiosity, I poked a bit around on
developer.apple.com, and stumbled over these pieces of docs:

http://developer.apple.com/techpubs/macosx/Darwin/General/IOKitFundamentals/ArchitectOverview/index.html
(titled "Controlling Devices From Outside the Kernel"):

    To answer this requirement, the I/O Kit includes two 
    mechanisms: device interfaces and POSIX device nodes. 
    Through a plug-in architecture and well-defined 
    interfaces, the device-interface mechanism enables a 
    program in user space to communicate with a nub in 
    the kernel that is appropriate to the type of device 
    it wishes to control. Through the nub the program 
    gains access to I/O Kit services and to the device 
    itself. For storage, serial, and networking devices, 
    applications can obtain the information they need 
    from the I/O Kit to access and control these devices 
    using POSIX APIs

http://developer.apple.com/techpubs/macosx/Darwin/General/IOKitFundamentals/ArchitectOverview/chapter_3_section_17.html
(titled "POSIX device files"):

     The I/O Kit dynamically creates the device files in 
     /dev as it discovers devices. Consequently, the set 
     of device files is constantly changing; different 
     devices might be attached to the device files in /dev 
     at any one time, and the same devices might have 
     different device-file names at different times. 
     Because of this, your application cannot hard-code 
     device file names. For a particular device, you must 
     obtain from the I/O Kit the path to its device file 
     through a procedure involving device matching. Once 
     you have the path, you can use POSIX APIs to access 
     the device.

So it seems that device files are indeed supported; I even found a PDF
(http://developer.apple.com/techpubs/macosx/Darwin/General/AccessingHardware/AccessingHardware.pdf)
that describes on page 41 and 42, how to create the device file name
with the help of the IO Kit. 

Assuming that access to device files will "survive" a fork() like with a
"real" Unix, this sounds like a better way to adapt Sane to MacOS X.
That's all pure theory though -- I have never worked with MacOS X...

Abel



More information about the sane-devel mailing list