[AGENT++] Async processing

M. Warner Losh imp at bsdimp.com
Mon Jan 24 07:06:57 CET 2005


In message: <41F29238.4040107 at omnesysindia.com>
            Arun <akumars at omnesysindia.com> writes:
: Jochen Katz wrote:
: 
: >> And then again while stepping into the code, i think i noticed a
: >> Sleep being called in win32 implementation. Why is a Sleep required
: >> in an Async setup ?
: >
: >
: > It's there to have the same "delay" for WIN32 and other systems. If 
: > you do "while (true) SNMPProcessPendingEvents();" on Unix you will get 
: > a CPU usage of 0%. For WIN32 without the sleep you will get 100%.
: 
: On all systems i intend to do a
:     while (true)
:         {
:         SNMPProcessPendingEvents();
:         DoSomeTimeSensiveRepetetiveTask();
:         if (required)
:              {
:              Sleep(precalculated-time);
:              }
:         }
: 
: Having a Sleep within the SNMPProcesspendingEvents makes my loop have a 
: minimum resolution of 1 sec, wheras at times i might not want to sleep 
: at all. I can easily prevent the 100% CPU time by having a Sleep within 
: my loop itself. Morover i can control the type/resolution of my sleep, 
: depending on the real-time system conditions.
: 
: I guess i could simply remove the Sleep from SNMP++ code and recompile 
: it for my use, but if there was some way to do handle this in a standard 
: manner, within the library iself, i would have preferred that.

I've fixed this on my Unix system by using select with a timeout
rather than a pure sleep.  I dig out the fd for the udp socket that
gets the snmp data and a couple of other sockets...

Warner



More information about the AGENTPP mailing list