Learn something new every day
More Info... by email
In software, the scheme of transactional memory is a course of action for multithreaded programming which uses transactions that are much like those that a database uses. When two or more threads attempt to access the same data at the same time, many different undesirable situations can result in cases where a program’s outcome depends on the thread access order. Usually, one order is desired and in multithreading, locks are the predominant and simplest way to ensure that only a single thread has access to a specific resource at a time.
This approach to transactional memory contains multiple problems in regards to locks in multithreading. A lock may become permanent if some kind of unanticipated error occurs, and locks can bring about unpredictable issues with concurrency, like deadlock or priority inversion. As a result of locks being very fine-grained, another issue includes the code eventually ending up spending a majority of time between locking, context switching, and unlocking. This is a crucial problem because it can result in the code spending more time on these actions than on doing other, important work in the program. In contrast, coarse-grained locks can cause decreased processing performance and decreased concurrency.
The problems in transactional memory are addressed by advanced locks, including “lock block” from C#, read-write locks, write barriers, etc. One of the main priorities in regards to transactional memory is to have no locks and no unnecessary lock processing time. It is usually agreed that a data structure that is shared is free of locks if mutual exclusion is not required by its operations. Data structures that are shared and free of locks avoid commonly associated problems with standard locking techniques if they are in systems that are highly concurrent.
The Transactional Memory Coherence and Consistency (TCC) model is a new, proposed model on shared memory. According to the model, atomic transactions are invariably basic units of the following: parallel work, memory coherence, communication, and consistency of memory reference. The TCC model also makes parallel software simpler by eliminating synchronization that uses standards locks or semaphores. Through hardware, TCC also combines every write from each region of transaction occurrence into one packet to atomically broadcast the packet to a memory state that is permanently shared. In addition to simplified coherence hardware, this means there is a reduction in low-dormancy messages needed and a complete elimination of certain, standard coherence protocols.