05.08.2014 Views

here - Stefan-Marr.de

here - Stefan-Marr.de

here - Stefan-Marr.de

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.3. Common Problems for the Implementation of Concurrency Abstractions<br />

introducing additional preemptive OS threads that schedule actors, i. e., tasks.<br />

Karmani et al. propose to use a monitoring thread. This thread will spawn<br />

additional threads if it does not observe progress. However, t<strong>here</strong> are limits<br />

to the approach and it requires tra<strong>de</strong>offs between application responsiveness,<br />

overhead, and monitoring precision. Furthermore, it can add complexity to<br />

the implementation since it prescribes how actors can be represented.<br />

Applicability beyond Actors Again, the problem of scheduling guarantees<br />

is not specific to actor-based concepts. Instead, it has to be carefully consi<strong>de</strong>red<br />

for any concurrent system that implies any notion of overall forward<br />

progress. The absence of such required guarantees is for instance visible in<br />

Clojure. Its agent construct makes a clear distinction between normal operations,<br />

and operations that result in long running computations or blocking<br />

I/O. For the latter kind of operations, Clojure offers the (send-off) construct,<br />

which will use a new thread to execute the operation to avoid starvation of<br />

other agents.<br />

Conclusion While ad hoc solutions used today have drawbacks, they provi<strong>de</strong><br />

the flexibility to implement custom policies that can be adapted precisely<br />

to the characteristics of a specific concurrent programming concept. The main<br />

problem with these approaches is the missing control over primitive execution<br />

and computationally expensive operations, which can prevent these ad hoc<br />

solutions from enforcing their policies.<br />

3.3.4. Immutability<br />

Immutability is a <strong>de</strong>sirable guarantee to simplify reasoning over programs in<br />

a concurrent setting, and it facilitates techniques such as replication, or constant<br />

propagation. However, in today’s VMs, immutability is guaranteed with<br />

limitations only. Often it is provi<strong>de</strong>d at the language-level only and not preserved<br />

at the VM level. For instance, the JVM and CLI allow a programmer to<br />

change final or readonly object fields via reflection. Nonetheless, it is used<br />

for optimizations, and the JVM specification inclu<strong>de</strong>s a warning on the visibility<br />

of such reflective changes, because JIT compilers for the JVM perform<br />

constant propagation for such fields.<br />

Weak immutability is a workaround for missing functionality. While immutability<br />

by itself is <strong>de</strong>sirable, notions of weak immutability have been used<br />

77

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

Saved successfully!

Ooh no, something went wrong!