Previous | Next --- Slide 22 of 60
Back to Lecture Thumbnails
kasia4

If we are assuming that we are only modifying nodes, we can assume that we implement a hand over hand locking scheme, until we only lock the node of interest, modify it, and unlock.

lonelymoon

From my understanding, this graph shows that if we use fine-grained locking, this will implement the function in a safe way to prevent unexpected multiple results. However, this also prevent concurrency and decreases the efficiency of implementation from parrallization.

haofeng

Fine-grained locks like the hand-over-hand lock are more efficient than locking the entire data structure. However, locking 2 to write 3 might block the writing of 4. Writing 3 and 4 concurrently does not violate the single writer multiple reader protocol, therefore the lock could be improved. As transactions are serialized, it is possible to determine that the conflict does not exist thus 3 and 4 can be updated concurrently.

jlara

The main benefit of transactions over fine-grained locking is their handling of parallelized read/write operations. By definition, transactions obey single-writer multipl-reader rules, while locks can't be used to distinguish between memory ops (at least not easily). For example, imagine any critical section where a lock is taken but the data being written/read would not conflict with another thread executing that critical section. Using a transaction instead would allow parallelism, while a lock would be too coarse to do the same.

Jonathan

I wonder if it ever makes sense to strike a balance between fine/coarse grained locking. For example, is it possible to have one lock "cover" multiple nodes in the tree such that you need fewer acquires than in the fine-grained case, but you end up with more parallelism than just having one lock for the entire tree.

Please log in to leave a comment.