That's a great point! ^ I was wondering in class if transactional memory is always better than locks. Are there any characteristics of TM that would make them worse than standard locks and mutexes?
@pranil I believe there's a graph comparing their runtimes on slide 27 and a few slides ago it talks about when you'd want to choose one over the other. It is interesting that CS110 spends so long introducing locks but doesn't mention transitional memory-- maybe it's because robust, working locks came around first and we've been using them since.
@jiaju I think it's also because locks can be used for more control of threads beyond atomic sections and provide more granularity like was mention elsewhere in these slides.
Please log in to leave a comment.
This issue would also come up if the atomic blocks were locked using a normal lock via .lock() and .unlock(), although it might be a bit clearer to a reader where the error is in the program if locks were used.