Beyond Simple Transactions and Atomic Blocks

نویسنده

  • Victor Luchangco
چکیده

Concurrent programming is notoriously difficult because actions by concurrent threads may be interleaved and result in unanticipated interactions, particularly on a shared-memory system. One mechanism proposed to address this difficulty is transactional memory (TM): programmers can group several operations into a transaction, which a TM implementation guarantees will appear to execute atomically,1 or not at all (i.e., the transaction is aborted). Thus, transactions reduce the possible interleavings and interactions that the programmer must consider. With transactional memory, it is easy to implement atomic blocks: one can simply execute the atomic block within a transaction, retrying in case the transaction aborts. Atomic blocks are typically implemented using locks to protect accessed data, in which the programmer must choose how to associate locks with data—trading simplicity against permissible concurrency—and manage the well known challenges of lock-based programming (e.g., the possibility of deadlock). Using transactions rather than locks, raises the level of abstraction, and shifts the responsibility of ensuring apparently atomic execution from the programmer to the system. Thus, programmers do not need to acquire the locks protecting the accessed data (and in such a way that avoids deadlock). Indeed, a TM implementation might not use locks to guarantee atomicity, but rather execute transactions optimistically, and abort those that will not appear atomic. However, transactional memory is not a panacea for concurrent programming: Many concurrent programs will require different kinds of synchronization, perhaps to avoid the overhead of implementing transactions or because another kind of synchronization is more “natural” in certain cases. For example, one thread may have to wait for another to compute a value (i.e., a producer-consumer pair). Or a thread may want to do some I/O (I/O is synchronization with the “user”). In addition, transactions may interact with other programming constructs even for a single thread, such as exceptions. For TM to be successful, its behavior with respect to these other kinds of synchronization and programming constructs must be well-defined, and preferably easy to understand. Some people suggest that transactional semantics should be defined in terms of locking semantics [13], and that TM should be considered a technique for implementing the semantics of a single global lock, but allowing greater concurrency than would be implied by actually having a single lock [3]. Although this may yield many of the performance benefits of TM, it gives up the conceptual benefits of TM, which I believe are ultimately more important. Key among these benefits is modularity: A transaction hides within itself the details of how it is implemented. The lack of this ability to hide implementation details is one of the chief reasons that lock-based programming is difficult: to avoid deadlock, a programmer must typically expose what locks may be acquired in a critical section, making the locks are part of the interface, not just the implementation. I hope that transactions can be to concurrent programming what functions are to sequential programming: the basic building blocks from which programs are constructed. This

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

A Concurrent Calculus with Atomic Transactions

The Software Transactional Memory (STM) model is an original approach for controlling concurrent accesses to ressources without the need for explicit lock-based synchronization mechanisms. A key feature of STM is to provide a way to group sequences of read and write actions inside atomic blocks, similar to database transactions, whose whole effect should occur atomically. In this paper, we inve...

متن کامل

Design choices for language-based transactions

This report discusses two design choices which arose in our recent work on introducing a new atomic keyword as an extension to the Java programming language. We discuss the extent to which programs using atomic blocks should be provided with an explicit ‘abort’ operation to roll-back the effects of the current block. We also discuss mechanisms for supporting blocks that perform I/O operations o...

متن کامل

Spectrophotometric determination of Dalacin phosphate from formulations using reduce atomic absorption of calcium ion by phosphate

A simple, sensitive and accurate method for spectrophotometric determination of Dalacinphosphatehas been established. The method is based on the reduction of atomic absorptioncalcium ion by phosphate. Because, there is a phosphate mole in every Dalacin mole structureand with measurement of phosphate, Dalacin is beyond measurement too. Therefore, the reactionbetween acidic hydrolysis products of...

متن کامل

Simple atomic blocks

• Atomic Blocks should be kept separate from heavier transactional notions (e.g. aborts, rollbacks). • Separate efficiency from correctness. There should be a simple correct (though possibly inefficient) implementation scheme for atomic blocks. But the performance-focused programmer should be able to add extra information (via annotations [4]) which may improve performance, without compromising...

متن کامل

Exceptions and Transactions in C++

There has been significant discussion—and significant disagreement—on the issue of how exceptions should interact with atomic blocks implemented using transactions. We present a proposal that offers a significant contribution towards resolving this issue, at least for C++, and we raise remaining areas of disagreement for discussion at the workshop and in the community in general.

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2009