05.08.2014 Views

here - Stefan-Marr.de

here - Stefan-Marr.de

here - Stefan-Marr.de

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6.2. Case Studies<br />

Important for this evaluation is that both, the ad hoc as well as the OMOPbased<br />

implementation provi<strong>de</strong> the same guarantees.<br />

General Implementation The general i<strong>de</strong>a behind the implemented STM is<br />

the same in both cases. To be precise, both of our implementations share the<br />

main co<strong>de</strong> parts, only the co<strong>de</strong> that realizes the capturing of field accesses is<br />

different.<br />

For the sake of brevity, the evaluation disregards LRSTM’s support for<br />

nested transactions, error handling, and other advanced features. The implementation<br />

discussed <strong>here</strong> is a sketch of a minimal STM system that enables<br />

atomic execution of transactions.<br />

The implementation sketch is given in Lst. 6.4. It builds on top of the ability<br />

to change all state access operations to work on a workingCopy of an object,<br />

instead of working on the object directly. To this end, in the context of a transaction<br />

each object can obtain a working copy for itself. A transaction maintains<br />

a set of changes, represented by Change objects. These change objects<br />

maintain the connection between the working copy and the original object,<br />

as well as a copy of the original object. Thus, all operations in the scope of<br />

a transaction result in read and write operations to the working copy of an<br />

object instead of changing the original.<br />

When a transaction is to be committed, all threads are stopped and the<br />

#commit operation checks for conflicting operations. #hasConflict checks<br />

whether the original object has changed compared to when the current transaction<br />

accessed it the first time. If no conflicts are found, the changes ma<strong>de</strong><br />

during the transaction are applied, and the commit succeeds.<br />

Managing State Access The main mechanism both implementations need to<br />

provi<strong>de</strong> is an interception of all state access operations. Thus, all field reads<br />

and writes need to be adapted to operate on a working copy instead of the<br />

original object. Furthermore, all primitives that read from or write to objects<br />

need to be adapted in a similar way.<br />

Ad Hoc Solutions Renggli and Nierstrasz [2007] proposed to use program<br />

transformation to weave in the necessary operations. Instead of using an<br />

AST transformation as done <strong>here</strong> (cf. Sec. 7.1), such adaptions could be applied<br />

with higher-level approaches such as aspect-oriented programming (cf.<br />

Sec. 7.1.3). The main requirement is that all field accesses are adaptable.<br />

149

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!