Re: [PATCH v3] tools: usb: aio example applications

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On 01/30/2014 03:09 PM, Michal Nazarewicz wrote:
>> This is not a good way to do this.  You are looping around with
>> 1 µseconds delays in each loop.  This is active polling and is not a way
>> to implement anything.  To properly use AIO with a single thread while
>> you also handling ep0, you need to use signals and ppoll.  In pseudo
>> code:
>> 
>> 1. Set up ep0, open up ep1.
>> 1. Set up SIGUSR1 handler to do nothing.
>> 2. Set up signal mask such that SIGUSR1 is blocked.
>> 3. Schedule transfers to ep1 if needed.
>> 4. Use ppoll with sigmask where SIGUSR1 is not blocked.
>> 5a. If ppoll returned SIGINTR io_getevents with a zero timeout.
>> 5b. If ppoll returned > 0, process ep0.
>> 5c. If ppoll returned < 0, exit with an error.
>> 6. Go to step 3.
>> 
>> Useful reading:
>> * man ppoll
>> * man sigevent
>> * man sigprocmask
>> 
>> You can find a bit of code that uses this technique at line 95 of:
>> https://github.com/mina86/p2p-chat/blob/master/src/application.cpp

On Tue, Feb 04 2014, Robert Baldyga wrote:
> This code is an example. Don't you think it would be better to keep it
> simple?

Sure, but it also has to be correct.  Busy waiting is *not* correct.

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<mpn@xxxxxxxxxx>--<xmpp:mina86@xxxxxxxxxx>--ooO--(_)--Ooo--

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux