On Thu, 17 May 2007, Hans Petter Selasky wrote: > Hi, > > On Thursday 17 May 2007 19:03, Alan Stern wrote: > > On Thu, 17 May 2007, Hans Petter Selasky wrote: > > > > In Linux, the USB callbacks are generally atomic. Does that answer > > > > your question? > > > > > > Yes. So you protect the callback with a lock to make it atomic? > > > > No, you don't understand. The callback is atomic because it is not > > allowed to sleep. That's what "atomic" means. It has nothing to do > > with locking or protection. > > And it cannot be interrupted either?
Some atomic routines can be interrupted and some can't. If an interrupt does occur then the interrupt handler is also atomic (by definition), so no problem will arise. As it happens, USB callbacks cannot be interrupted. That's a somewhat artificial restriction; in theory there's no reason we couldn't allow interrupts. > > With pre-allocation you might fail at the beginning, and with late > > allocation you might fail in the middle. Either way, you fail. So > > what's the big deal? > > There is a greater chance of successing with pre-allocation if you use the > wait flag when you malloc? Right? Certainly. But turn it around: With pre-allocation you force other parts of the system to have a higher chance of failing, because you already own the memory they want (even though you may not be using it). Alan Stern ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel