A Fully Abstract Game Semantics for Parallelism with Non-Blocking Synchronization on Shared Variables
A Fully Abstract Game Semantics for Parallelism
with Non-Blocking Synchronization on Shared
Variables
Susumu Nishimura
Dept. of Mathematics, Graduate School of Science, Kyoto University
Sakyo-ku, Kyoto 606-8502, JAPAN
Abstract
We present a fully abstract game semantics for an Algol-like parallel language with non-blocking
synchronization primitive. Elaborating on Harmer’s game model for nondeterminism, we develop
a game framework appropriate for modeling parallelism. The game is a sophistication of the waitnotify game proposed in a previous work, which makes the signals for thread scheduling explicit
with a certain set of extra moves. The extra moves induce a Kleisli category of games, on which
we develop a game semantics of the Algol-like parallel language and establish the full abstraction
result with a significant use of the non-blocking synchronization operation.
1998 ACM Subject Classification F.3.2 Semantics of Programming Languages, F.1.1 Models of
Computation, F.1.2 Modes of Computation
Keywords and phrases shared variable parallelism, non-blocking synchronization, full abstraction, game semantics
Digital Object Identifier 10.4230/LIPIcs.CSL.2013.578
1
Introduction
In shared memory parallel programming, parallel threads competing for shared memory
cells (or shared variables) must be appropriately synchronized to avoid race conditions. A
synchronization method is called non-blocking, if each individual thread spins over a shared
resource until it acquires an exclusive access to it. In contemporary architectures including
multicores, non-blocking synchronization is supported via the read-modify-write operation,
most notably known as compare-and-set (CAS) operation. [12]
This paper concerns with game theoretical analysis of an Algol-like parallel language that
supports non-blocking synchronization on shared variables. Game semantics for PCF and
Idealized Algol have been well investigated and shown fully abstract [13, 3]. However, the
standard methods used in the game modeling do not directly apply to the parallel extension
considered in this paper:
The models for the above deterministic languages solely concern may-convergence, i.e.,
they just observe if a program has the possibility of termination. The parallel programs,
on the other hand, are inherently nondeterministic and thus may-convergence is too
imprecise to give a pleasant discrimination of parallel programs: Even if two programs
are judged equivalent, they can nondeterministically exhibit different convergences.
One might expect that the parallel execution would be modeled by interleaved game plays
of simultaneously running threads, but this fails to properly shuffle variable accesses,
due to the parity restriction originating from the Hyland-Ong game [13], in which the
opponent moves and the player moves must strictly alternate.
© Susumu Nishimura;
licensed under Creative Commons License CC-BY
Computer Science Logic 2013 (CSL’13).
Editor: Simona Ronchi Della Rocca; pp. 578–596
Leibniz International Proceedings in Informatics
Schloss Dagstuhl – Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany
S. Nishimura
579
In a preliminary work [20], Watanabe and the present author proposed wait-notify games
as a means to remedy the above issues. They developed the wait-notify games based on
Harmer’s game semantics [9, 10], in order to capture the nondeterministic nature of parallel
computation more precisely. Harmer’s games substantially extend Hyland-Ong’s with the
notion of divergence, giving the full abstraction result for a nondeterministic variant of
Algol-like sequential language. It concerns both may-convergence and must-convergence,
i.e., it also discriminates those programs which are obliged to terminate from those which
are not.
The fundamental idea in wait-notify games is to have each game play interspersed by a
suitable number of pairs of extra wait and notify moves, written W and N, respectively. A
wait move W represents a delay imposed by the scheduler of the operating system, each time
a single execution thread attempts to access a shared variable; A subsequent notify move N
represents the resumption of the delayed variable access by the scheduler. However, waitnotify games are defined only for the type of parallel computation and are not well integrated
with the computational structure of other types, including higher-order ones. The resulting
parallel language thereby supports parallelism only under a fairly limited context: Within
parallel contexts, nothing but shared variables can be parametrized.
The present paper sophisticates the idea in the wait-notify game to give a fully abstract
game semantics for an Algol-like parallel language with non-blocking synchronization, in
which parallelism is allowed under much wider contexts of arbitrary types, though subject
to a few modest syntactic restrictions. We will develop the game model in a Kleisli category
of games, induced from the monadic structure introduced by the wait and notify moves.
This not only enables us to reach to the full abstraction result in a standard way but also
reveals the computational structure hindered behind the parallel computation.
Here we emphasize that we do not intend to model parallel computation as a game
between individual parallel threads. Rather, we model parallel computation as a game
between the collection of simultaneously running threads and the scheduler, which is the
entity invisible in the program text. The extra wait and notify moves enable the game
semantical construction with the scheduler’s interference explicit. The extra moves, on the
other hand, should not be counted when we discuss observational behavior of programs.
Thus we need to introduce a scheduler strategy that ignores these extra moves all together,
later in Section 5.
The development in this paper also gives some indications on the nature of parallel
computing:
As we will discuss later, the game model in this paper has no ability to observe the
termination of the entire collection of threads running in parallel. This implies that no
language whose parallel running threads can join to a single sequential thread would be
fully abstract with respect to the present game model or its modest extension. Due to
this fact, we are driven to design our parallel language so that no parallel threads join:
There is no means to merge the set of parallel threads into a single sequential thread,
even after all the parallel threads have terminated.
In the course of establishing full abstraction, we need to separate out a history-insensitive
part from a given game strategy. This is usually done by the so-called innocent factorization [3], which does not directly apply to our parallel setting, though. The parallel
threads would compete for a shared variable in which the factorized strategy keeps the
history. There we make an indispensable use of the non-blocking synchronization operation CAS, as a means for mutual exclusion on the shared varia (...truncated)