Section: New Results
Models and semantics
Participants : Gérard Berry, Gérard Boudol, Gustavo Petri, Christian Queinnec, Manuel Serrano.
Semantics of concurrent programming
We are investigating the theory of multithreading. Multithreading is a form of concurrent programming where sequential programs (threads) run in parallel and communicate via a shared mutable store. Parallel execution is usually ruled according to some scheduling policy (in our work we consider preemptive, non-deterministic scheduling, that is the standard interleaving model), and controlled, from the threads, by means of synchronization constructs, like acquiring and releasing locks. It is well-known that this model is not correctly implemented in optimized execution platforms introducing some further parallelism in the computation, for instance in the accesses to the shared memory, like in weak memory models. Our work of last year on the write- buffering memory model has been published this year, see  . We have extended our approach to capture more relaxed memory models and, more generally, relaxed execution models where pieces of code can be executed in advance (or in parallel with the rest of the program), like with the write-buffers memory model where the updates to the memory are issued, and placed in buffers, while pursuing with the rest of the program. Such optimization mechanisms are known as speculative computation . We have proposed a formalization of a fully general notion of speculative computation, including branch prediction and value prediction. This is done in  for an expressive language (CoreML, or CoreScheme, that is the functional and imperative fragment of these languages, enriched with concurrent programming constructs) by means of Berry and Lévy's equivalence by permutation of computations. We have to define in particular a notion of valid speculation, since some speculative computation may be exploring the wrong branch in a conditional branching sub-program, the condition of which is not yet determined. We have shown that, for programs enjoying the property that their speculative execution does not create data-races (hence in particular for sequential programs), the speculative semantics correctly implements the standard interleaving semantics. We also propose in  a source programming language where a distinction is explicitly made between shared and private variables, and where we introduce a synchronization construct for temporarily having exclusive access to a shared variable. We show that, guided by a type and effect system guaranteeing that a private variable is indeed not shared, we can translate the (typable) programs of this language into programs that are correctly executed in the speculative semantics.
Regarding the latter core language for multithreaded programming, we have investigated another problem, namely the one of deadlocks. It is well-known that synchronization is needed to ensure exclusive access to shared data (like in updating a bank account, for instance), but that synchronization usually introduces deadlocks, a configuration where some threads cannot make any progress, being circularly blocked in waiting for a resource held by another thread. This is a kind of error that must be dealt with, and there are three techniques to do so: deadlock prevention (usually by means of static analysis or verification), deadlock detection and recovery (by means of a monitoring mechanism involving roll-back), and deadlock avoidance. Surprisingly enough, the last technique has not been explored at the programming language level. In  , we design, for a language similar to the one of  , a type and effect system where the locks that are anticipated to be acquired are recorded in the effect of a program. Then, guided by this analysis, we design a semantics where a lock is acquired only if no other lock that could be acquired in the future, that is, a lock in the effect of the program, is already held by another thread. We show that this provides, for typable programs, a deadlock-free semantics.
A multi-tier semantics for Hop
This semantics details the programming model advocated by Hop and provides a sound basis for future studies such as web continuations and concurrency. The semantics has been presented at the event dedicated to Mitch Wand that took place in Boston in August.