Question: Give an example of synchronization "not being needed" in the case of two threads simultaneously accessing the hashtable.
Qiaoyu
@kayvonf, something like two threads are accessing the the hash table, but the idx they got from hash(key) is different? which means they are accessing different bucket at the the time. In that situation, they do not need to get lock first, since they will not get collided, but if we program it as acquiring lock first, they will waste time on getting mutex. So, if we can implement transaction memory on it, only when necessary we will waste much time to do deal race condition, we could save a lot of time.
Master
If only two threads are looking up the hash table concurrently, synchronization is unnecessary.
sreevisp
To elaborate on Master's comment - any number of threads can do lookups in the hash table concurrently as long as none of them are writing to it.
Question: Give an example of synchronization "not being needed" in the case of two threads simultaneously accessing the hashtable.
@kayvonf, something like two threads are accessing the the hash table, but the idx they got from hash(key) is different? which means they are accessing different bucket at the the time. In that situation, they do not need to get lock first, since they will not get collided, but if we program it as acquiring lock first, they will waste time on getting mutex. So, if we can implement transaction memory on it, only when necessary we will waste much time to do deal race condition, we could save a lot of time.
If only two threads are looking up the hash table concurrently, synchronization is unnecessary.
To elaborate on Master's comment - any number of threads can do lookups in the hash table concurrently as long as none of them are writing to it.