Hello, Yes you are right that lock should be taken on all areas where the shared CONTAINER is being used/accessed I have a query related to this only
I have alarmTable mib module The alarmTable CONTAINER will be accessed by 2 different threads 1) netsnmp thread for GET/SET operations 2) my subagent(master-subagent configuration) thread which will continously updating this container with new alarms recieved As this is a table so using mib2c.array.conf it gave me folowing methods: currentAlarmTable_cmp() currentAlarmTable_get() init_currentAlarmTable() currentAlarmTable_row_copy() currentAlarmTable_extract_index() currentAlarmTable_can_delete() currentAlarmTable_duplicate_row() currentAlarmTable_delete_row() currentAlarmTable_set_reserve1() currentAlarmTable_set_reserve2() currentAlarmTable_set_action() currentAlarmTable_set_commit() currentAlarmTable_set_free() currentAlarmTable_set_undo() initialize_table_currentAlarmTable() currentAlarmTable_get_value() currentAlarmTable_get_by_idx() updateCurrentAlarmTable_MyOwnMethod()--->In this method i do CONTAINER.INSERT() So in order to have syncronization i am using mutex and condition variable. But i am not sure where all to use mutexs. I am using mutexes in following places : updateCurrentAlarmTable_MyOwnMethod() initialize_table_currentAlarmTable() Do i also need to take lock on following methods provided by netsnmp currentAlarmTable_set_reserve1() currentAlarmTable_set_reserve2() currentAlarmTable_set_action() currentAlarmTable_set_commit() currentAlarmTable_set_free() currentAlarmTable_set_undo() currentAlarmTable_get_value() as they also access CONTAINER ----- Original Message ----- From: Dave Shield <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Cc: [email protected] Sent: Fri, 20 Jun 2008 14:30:34 +0530 (IST) Subject: Re: Multithreaded : IS IT Safe to create new thread for updating CONTAINERS 2008/6/19 <[EMAIL PROTECTED]>: > I created a new thread and... in this thread only,i updated the NetSNMP > CONTAINER using > CONTAINER.INSERT() and took a mutex before updating it. That's half of the task, yes. But as I understand threading (and I am *not* an expert in this field), you will also need to have a corresponding lock around the code that *uses* this container. I.e. the code for your MIB module (and any helpers that it might rely on). You will need to look closely at the code that implements your MIB module, to see exactly where the container is referenced, and hence the region you need to protect with the lock. Dave ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Net-snmp-coders mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
