Michal Misiak Java Blog

Quiescent Consistency

An execution of a concurrent program is quiescently consistent if the method calls can be correctly arranged retaining the mutual order of calls separated by quiescence, a period of time where no method is being called in any thread. Quiescent consistency semantics impose less restrictions than strong consistency model — linearizability, allowing for greater freedom in implementing concurrent programs. It is appropriate for applications that require high performance at the cost of placing relatively weak constraints on object behaviour.The implications of the relaxed constraints and various aspects of quiescent consistency are described in this article. All the examples are written in Java 1.8 and tested using Java HotSpot(TM) virtual machine.

Fence-ing with Memory — Memory Reordering in Peterson Lock

Peterson Lock is a simple algorithm allowing two processes to synchronize access to a critical section — mutual exclusion. Basing on the implementation of the algorithm in Java, we show how the Java Memory Model may affect the execution of a Java code. The reasons are twofold: JIT compiler optimizations and CPU memory reordering. In this article, they are both examined, JIT compiler outputs are analyzed and finally a C implementation of Peterson Lock is presented to verify memory reordering on CPU level.In addition a piggybacking technique is explained to show an efficient way of using memory barriers. All the programs were tested on Intel 64 and IA-32 architecture processors.