A method, system and computer program product for eliminating memory corruption
when performing multi-threaded tree operations. A network processor may receive
a command to perform a tree operation on a tree on one or more of multiple threads.
Upon performing the requested tree operation, the network processor may lock one
or more resources during a portion of the execution of the requested tree operation
using one or more semaphores. A semaphore may refer to a flag used to indicate
whether to "lock" or make available the resource associated with the semaphore.
Locking may refer to preventing the resource from being available to other threads.
Hence, by locking one or more resources during a portion of the tree operation,
memory corruption may be eliminated in a multiple thread system while preventing
these resources from being used by other threads for a minimal amount of time.