Software Transactional Memory
페이지 정보
작성자 Reinaldo 작성일25-08-17 12:24 조회3회 댓글0건관련링크
본문
In pc science, software program transactional memory (STM) is a concurrency management mechanism analogous to database transactions for controlling entry to shared memory in concurrent computing. It's another to lock-based mostly synchronization. STM is a method implemented in software program, slightly than as a hardware part. A transaction in this context happens when a bit of code executes a sequence of reads and writes to shared memory. These reads and writes logically occur at a single instant in time; intermediate states are not seen to other (profitable) transactions. The concept of providing hardware support for transactions originated in a 1986 paper by Tom Knight. The thought was popularized by Maurice Herlihy and J. Eliot B. Moss. In 1995, Nir Shavit and Dan Touitou extended this concept to software-solely transactional memory (STM). Not like the locking strategies utilized in most trendy multithreaded purposes, STM is usually very optimistic: a thread completes modifications to shared memory without regard for what other threads is perhaps doing, recording each read and write that it's performing in a log.
As an alternative of placing the onus on the author to ensure it does not adversely affect other operations in progress, MemoryWave Guide it's positioned on the reader, who after completing a whole transaction verifies that other threads have not concurrently made adjustments to memory that it accessed up to now. This remaining operation, wherein the modifications of a transaction are validated and, if validation is successful, made permanent, is known as a commit. A transaction may additionally abort at any time, inflicting all of its prior changes to be rolled again or undone. If a transaction can't be committed as a result of conflicting adjustments, it is often aborted and re-executed from the beginning till it succeeds. The good thing about this optimistic approach is increased concurrency: no thread must anticipate access to a resource, and completely different threads can safely and simultaneously modify disjoint elements of a data structure that will normally be protected beneath the same lock.
However, in apply, STM systems additionally endure a efficiency hit in comparison with tremendous-grained lock-primarily based techniques on small numbers of processors (1 to four relying on the appliance). That is due primarily to the overhead related to maintaining the log and the time spent committing transactions. Even in this case performance is often no worse than twice as gradual. Advocates of STM believe this penalty is justified by the conceptual advantages of STM. Theoretically, MemoryWave Guide the worst case area and time complexity of n concurrent transactions is O(n). Actual needs depend upon implementation particulars (one could make transactions fail early sufficient to keep away from overhead), however there will also be circumstances, Memory Wave albeit rare, the place lock-based algorithms have higher time complexity than software transactional memory. STM significantly simplifies conceptual understanding of multithreaded applications and helps make programs more maintainable by working in harmony with current excessive-degree abstractions comparable to objects and modules. Locking requires enthusiastic about overlapping operations and partial operations in distantly separated and seemingly unrelated sections of code, a job which may be very tough and error-prone.
Locking requires programmers to adopt a locking coverage to stop deadlock, livelock, and other failures to make progress. Such policies are sometimes informally enforced and Memory Wave fallible, and when these issues arise they're insidiously troublesome to reproduce and debug. Locking can lead to priority inversion, a phenomenon the place a excessive-priority thread is forced to look ahead to a low-precedence thread holding exclusive entry to a useful resource that it wants. In contrast, the idea of a memory transaction is way easier, as a result of every transaction could be seen in isolation as a single-threaded computation. Deadlock and livelock are both prevented totally or handled by an exterior transaction manager; the programmer want hardly fear about it. Precedence inversion can nonetheless be an issue, however high-priority transactions can abort conflicting decrease priority transactions that have not already committed. Nonetheless, the necessity to retry and abort transactions limits their conduct. Any operation performed inside a transaction should be idempotent since a transaction may be retried. Additionally, if an operation has uncomfortable side effects that should be undone if the transaction is aborted, then a corresponding rollback operation have to be included.
This makes many input/output (I/O) operations difficult or not possible to perform inside transactions. Such limits are sometimes overcome in apply by creating buffers that queue up the irreversible operations and perform them after the transaction succeeds. In Haskell, this restrict is enforced at compile time by the type system. In 2005, Tim Harris, Simon Marlow, Simon Peyton Jones, and Maurice Herlihy described an STM system built on Concurrent Haskell that allows arbitrary atomic operations to be composed into bigger atomic operations, a helpful concept unimaginable with lock-based programming. For instance, consider a hash table with thread-safe insert and delete operations. Now suppose that we wish to delete one merchandise A from table t1, and insert it into desk t2; however the intermediate state (by which neither table accommodates the merchandise) should not be visible to other threads. Until the implementor of the hash desk anticipates this want, there is solely no option to satisfy this requirement. In short, operations which can be individually right (insert, delete) can't be composed into larger right operations.
댓글목록
등록된 댓글이 없습니다.