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.

3. Which Concepts for Concurrent and Parallel Progr. does a VM need to Support?<br />

<strong>de</strong>fines that each object is implicitly associated with a lock to enable synchronized<br />

methods. The metadata associated with every method, which is part of<br />

the ISA, has t<strong>here</strong>fore to contain the ImplFlags.Synchronized flag, according<br />

to the specification. Other atomic and synchronization operations are <strong>de</strong>fined<br />

in terms of primitives for instance for compare-and-swap, atomic update operations,<br />

and explicit memory barriers, i. e., fences.<br />

Beyond these mechanisms, the specification also discusses the functions<br />

Parallel.For, Parallel.ForEach, and Parallel.While. They are part of the<br />

standard library to provi<strong>de</strong> parallel looping constructs. With the notion of<br />

AppDomains it also inclu<strong>de</strong>s a mechanism to facilitate communicating isolates,<br />

which is discussed in Sec. 3.1.2.3.<br />

Java Virtual Machine (JVM) The analysis of the Java Virtual Machine (JVM)<br />

relies on the specification [Lindholm et al., 2012] and consi<strong>de</strong>rs the OpenJDK7<br />

for <strong>de</strong>tails about the standard library.<br />

The JVM provi<strong>de</strong>s a programming mo<strong>de</strong>l that is solely based on shared<br />

memory. It relies on the memory mo<strong>de</strong>l <strong>de</strong>fined by the Java Language Specification<br />

[Gosling et al., 2012] to establish the semantics of operations on this<br />

shared memory and the visibility of changes to the memory between operations<br />

and threads. The semantics are <strong>de</strong>fined in terms of happens-before relationships<br />

between operations. For example, synchronization operations as<br />

well as reading and writing of volatile fields have specific semantics, which<br />

constrain optimizations of compilers and processors to guarantee that the<br />

observable or<strong>de</strong>ring of operations is <strong>de</strong>terministic. Similar to the CLI, these<br />

semantics are realized in terms of the implicit semantics implemented in the<br />

VM and its JIT compiler.<br />

In addition to the memory mo<strong>de</strong>l, locking-based abstractions are a key concurrency<br />

feature, because every object is implicitly associated with a lock to<br />

enable synchronized methods and can also be used as a condition variable.<br />

Methods can carry the ACC_SYNCHRONIZED flag, and the two byteco<strong>de</strong> instructions<br />

monitorenter and monitorexit expose the object’s lock on the ISA level<br />

to enable the implementation of synchronized blocks. A note in the specification<br />

also hints at Object.wait and Object.notify being realized as primitives.<br />

In contrast to the CLI, the JVM does not have the notion of volatile<br />

variables, because it does not have closures. Instead, it provi<strong>de</strong>s only volatile<br />

object fields, which are realized in the ISA by a the ACC_VOLATILE flag in the<br />

object field’s metadata.<br />

46

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

Saved successfully!

Ooh no, something went wrong!