Previous | Next --- Slide 11 of 60
Back to Lecture Thumbnails
ipadpro

I am wondering that if the key/values are simple integers and they perfectly align in memory, does that mean each read/write operation will still get the correct value from the memory address without synchronization?

Each read/write is (kind of) atomic, since only one thread can update a value at the same time. There won't be cases where one thread is still writing a value to memory and another thread changed some bits.

Is it possible that we can achieve a lock-free thread-safe HashMap in this case?

assignment7

I think that this lock-free and thread-safe HashMap can be achieved only when we have a perfect hash function, and have only one element per bucket. If we have longer linked lists in the buskets and two calls map to the same linked list, then we can not guarantee thread safety.

teapot

I think in real data structure designs, there are other limits such as member variables (e.g. size of the container) that prevents multiple threads accessing the same function concurrently?

Please log in to leave a comment.