home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,558 of 33,346   
   James K. Lowden to fmatthew5876@googlemail.com   
   Re: IO thread, block or destroy/recreate   
   25 Sep 12 07:28:28   
   
   From: jklowden@speakeasy.net   
      
   On Mon, 24 Sep 2012 12:20:31 CST   
   fmatthew5876  wrote:   
      
   > > Before answering you specific question, I would comment that I would   
   > > try to avoid polling.   
   > >   
   > In almost any other application I would agree. However in a game   
   > that runs its main loop 60 times per second, I think polling to see   
   > if the IO is done each frame makes sense.   
      
   Why?  Machines are fast and people are slow.  Even *video* is slow if   
   you're talking about refresh rates.   
      
   A pretty slow processor these days executes a billion or so cycles per   
   second, and instructions take under 100 cycles.  A 100-cycle   
   instruction called 100 times a second would use less than 0.001% of   
   the processor's capacity.   
      
   In "The Linux Programming Interface", Michael Kerrisk talks about   
   getpid(2), something *much* heavier weight than blocking on a thread:   
      
   	"On one of the author?s x86-32 systems running Linux 2.6.25,   
   10 million calls to getppid() required approximately 2.2 seconds to   
   complete. This amounts to around 0.3 microseconds per call. By   
   comparison, on the same system, 10 million calls to a C function that   
   simply returns an integer required 0.11 seconds, or around   
   one-twentieth of the time required for calls to getppid()."   
      
   IOW he could call getpid 75,000 times in 1/60 of a second.  Give or   
   take an order of magnitude, you probably can, too.   
      
   --jkl   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca