From: Ned K. <ne...@bi...> - 2006-04-04 06:23:07
|
On Apr 3, 2006, at 3:08 PM, Joerg Wunsch wrote: > As Ned Konz wrote: > >> So at least we've figured out some of the problem: you can't open a >> USB device in one process and hand it to another, even a child >> process. > > Too bad. > >> Can this be fixed? > > Not very easily. The main reason for all that dreadful stuff with > forking off a "USB daemon" is that AVaRICE has a rather hard-coded > idea to use select() in order to multiplex for events from both, the > JTAG ICE, as well as the stream backend to GDB. This works pretty > well with a serial line on one side, and a socket on the other end, > but completely doesn't fit at all into the libusb model as the libusb > API doesn't use file descriptors for communication with its caller but > rather some internal library handle. Thus, the "USB daemon" is > basically my way to convert the library handle into a file descriptor > (actually a pipe to the parent). > > Setting up the entire libusb stuff inside the child process might be > possible, but requires some means of communicating all the potential > setup problems back to the parent (and be it a SIGPIPE or such), so a > number of things probably need to be rewritten. I'm open for patches > on this. What we did in Squeak (where we had the problem that various plugins might want to get notifications on async file operation completion, but we still had some that weren't using file descriptors) was to use select, but with a rather short polling timeout. So we'd do a select, process any file handles that were ready, then call any other interested parties. This guaranteed a worst-case polling time, but still was relatively light-weight from an OS point of view (since most of the time was still spent sleeping waiting for select()). -- Ned Konz ne...@bi... |