Suppose I have a data structure S in memory. S is complex, say a tree or a graph. I have two threads travelling through S, and they may hit and try to read the same address at the same time. My question is: is there any kind of implicit locking at this point such that contention between the threads arises? If it is of value, I'm using C, pthreads on a regular SMP machine.
No. There is no need for locking with read-only operations.
There would only be locking if you explicitly implement it. This would usually be done when there's a chance of another thread modifying (writing) the structure at the same time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With