[AGENT++] snmp++ construction blocked in multi-thread in windows2000 server on multi-cpu machines ?

shenmingda shenmd at nlsde.buaa.edu.cn
Wed Sep 15 03:52:09 CEST 2004


Hello Jochen Katz,
      look at the constructor of snmp class ,in my oponion,what cause createwindow api consume so much time is because of the window class registered have a no well defined message processing function(but SnmpWndProc only process wm_create message and return when creation,i don't think there will be any problem), coz SNMP_WAIT will block the other threads until be signaled when leave the critical section, so multi-thread did'nt achive enough effiency,then i take this line out of the critical section by adding wait and signal before and after it, so my assumption my multi-thread ,even though this api will take so much,the time consumed will be paralled, and in my application,i should assure that every thread will have only on snmp object,and the thread will no exit to keep the window created alive,that'll release the misery snmp++ brought me as much as possible :《
      as far as i know,my strategy works and the multi-thread on multi-cpu didnt' appear to be blocked any more, thanks.                          
       
//----------------------------------------------------------------------
//------[ Snmp Class Constructor ]--------------------------------------
//----------------------------------------------------------------------
Snmp::Snmp( int &status, unsigned short agent_port)  // status of construction
{
   SNMPDEBUG("++ SNMP++, SNMP Constructor \n");
   SNMPAPI_STATUS WinSnmpStatus;    // return status for snmp calls
    SNMP_WAIT;                      
   // call transport start up if it hasn't been called before 
   construct_status = SNMP_CLASS_SUCCESS;
   if ( snmp_ref_count == 0)
   {
       status = transport_start_up();
       construct_status = status;
       if ( status != SNMP_CLASS_SUCCESS)
       {
           SNMPDEBUG("-- SNMP++, Transport Start Up Failure \n");
		   SNMP_SIGNAL;
           return;
       }    
   }
   snmp_ref_count++;                          // bump up the ref count
   
   SNMPDEBUG("++ SNMP++, SNMP Constructor createwindow \n");
   SNMP_SIGNAL;
   ~~~~~~~~~~~~~
   pdu_handler = CreateWindow( SzSnmpClass,   // name of class
   ~~~~~~~~~~~~~~~~~~~~~~~~~   NULL,          // window text 
                               WS_POPUP,      // window style
                               0,             // xpos
                               0,             // ypos
                               0,             // width
                               0,             // hieght
                               0,             // parent window handle, none for popup
                               0 ,            // window id
                               0,             // parent instance
                               0);            // pointer to construct data


   SNMP_WAIT;
~~~~~~~~~~~~~~~~~~~~~~
   if ( pdu_handler == NULL)
   {
    ......
   }
   else
   {
   
      ...........
         // success
         status = SNMP_CLASS_SUCCESS;
		 SNMP_SIGNAL;
		 SNMPDEBUG("leave ++ SNMP++, SNMP Constructor \n");
         return;
     
   }
};


Best regards, 
  
======= At 2004-09-15, 02:15:21 you wrote: =======

>Hi,
>
>> i found that the snmp++ construction function will be blocked when my
>> 200 thread concurrently called it , i tracked into the function,and
>> find that the most suspicious root is the createwindow api,
>
>snmp++ does not create any GUI windows. So please give more details
>where you think a lot of time is consumed.
>
>Regards,
>  Jochen
>
>

= = = = = = = = = = = = = = = = = = = =
			
shenmingda
shenmd at nlsde.buaa.edu.cn
2004-09-15



More information about the AGENTPP mailing list