What is the transactional memory in comparison to actor-based and lock-based synchronization?
As far as I understand it is another mechanism of concurrency control. Or it is something completely different to actors, events, locks etc.?
What is the transactional memory in comparison to actor-based and lock-based synchronization?
As far as I understand it is another mechanism of concurrency control. Or it is something completely different to actors, events, locks etc.?
Transactional Memory (TM) is a lock free synchronization methodology. In a lock based synchronization mechanism, one thread acquires the lock and enters the synchronized block whilst others wait until the lock becomes available. In TM, threads don't wait for the lock, each of them continue as if the lock is available. However in order to ensure the correctness of the execution, all the memory accesses made inside the synchronized block are made speculatively. Once the execution reaches the end of the synchronized region, threads communicate with each other and share memory locations read and written (called read set and write set in TM terminology). If a thread has read a memory location that has been written speculatively by another thread, a conflict has happened and conflict resolution will takes place. In the end, if two or more threads have no conflicts, they both can continue and will update the memory with speculative writes. Despite the complexity involved with the implementation, you get the advantage of finer grained locking (based on memory locations) with a program written similar to a coarse grained lock (you only need to specify the start and end of a transaction).
There are dozens of TM systems based on how you do the versioning of data (original data vs speculative data) and conflict resolution (eager - do as you go, lazy - do it in the end). Also the platform they are implemented in (Hardware, Software, HyBrid).
I am not very good with actor based concurrency. With my limited knowledge, it appears to be working by sending messages to other actors and each actor does the work it is being asked to do and create more actors if it requires. So I guess conceptually it is similar to a divide and conquer style programing where work is created on the fly and being passed around available actors. This type of paradigm, similar to functional programming, goes orthogonal to the traditional shared memory style where synchronization is needed. Therefore I guess, actor based models, do not require locks or lock free synchronization as they are inherently parallel.
© 2022 - 2024 — McMap. All rights reserved.