[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Flushing af stdin



Mads Bondo Dydensborg <sslug@sslug> wrote:

...

>> MEN, hvad der der galt med select(2) ?
>> Er den for svært at anvende ?

> Som jeg opfattede det, venter select et stykke tid. Med gettimeofday får
> man tidspunktet på dagen.

Select venter kun et stykke tid hvis der ikke er input, og man kan
selv sætte timeout-tiden.
Der var jo i eksemplet et sleep()/usleep() så om man venter det ene 
eller andet sted er vel ikke så relevant.

> Det er da to forskellige ting. gettimeofday er således mere generel.

Ja, hvis man skal have tiden på dagen. 
Men ok, er det busy-waiting-løkker vi skal have, så er det vel ok :)

At bruge select() kræver at man tænker lidt anderledes , men den
er vel mere generel. Fra manual siden select(2) :

       timeout  is  an  upper bound on the amount of time elapsed
       before select returns. It may be zero, causing  select  to
       return  immediately.  If  timeout  is  NULL  (no timeout),
       select can block indefinitely.


dvs:

   time = 0  returner omgående
   time > 0  returner senest efter "time"
   time= NULL vent til der er input i file descriptor listen.


-- 
mvh Frank Damgaard  | http://home3.inet.tele.dk/frda/



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *