Table of Contents
Fetching ...

An Efficient Implementation of Guard-Based Synchronization for an Object-Oriented Programming Language

Shucai Yao, Emil Sekerinski

TL;DR

This work tackles efficient execution of guarded atomic actions in shared-variable concurrency by unifying the unit of concurrency with objects in an OO setting. It introduces Lime, a language where guards are expressed as $g$ and guarded commands take the form $g \to S$, with atomicity limited to method calls and parallel object execution enabled by cooperative scheduling of per-object coroutines. The runtime maps active objects to a small number of worker threads, uses segmented stacks, and relies on lock-free local/global queues with work stealing to balance load, achieving efficient guard evaluation and avoiding backtracking. Experimental results on synthetic benchmarks (priority queue, leaf-oriented tree, map-reduce) show Lime and other lightweight runtimes outperform heavyweight models like Java and C/Pthreads, demonstrating practical viability of guard-based synchronization in object-oriented languages.

Abstract

In the shared variable model of concurrency, guarded atomic actions restrict the possible interference between processes by regions of atomic execution. The guard specifies the condition for entering an atomic region. That is a convenient model for the specification and verification of concurrent programs, but has eschewed efficient execution so far. This article shows how guarded atomic actions, when attached to objects, can be implemented highly efficiently using a combination of coroutines, operating-system worker threads, and dedicated management of object queues and stacks. The efficiency of an experimental language, Lime, is shown to compare favourably with that of C/Pthreads, Go, Erlang, Java, and Haskell on synthetic benchmarks.

An Efficient Implementation of Guard-Based Synchronization for an Object-Oriented Programming Language

TL;DR

This work tackles efficient execution of guarded atomic actions in shared-variable concurrency by unifying the unit of concurrency with objects in an OO setting. It introduces Lime, a language where guards are expressed as and guarded commands take the form , with atomicity limited to method calls and parallel object execution enabled by cooperative scheduling of per-object coroutines. The runtime maps active objects to a small number of worker threads, uses segmented stacks, and relies on lock-free local/global queues with work stealing to balance load, achieving efficient guard evaluation and avoiding backtracking. Experimental results on synthetic benchmarks (priority queue, leaf-oriented tree, map-reduce) show Lime and other lightweight runtimes outperform heavyweight models like Java and C/Pthreads, demonstrating practical viability of guard-based synchronization in object-oriented languages.

Abstract

In the shared variable model of concurrency, guarded atomic actions restrict the possible interference between processes by regions of atomic execution. The guard specifies the condition for entering an atomic region. That is a convenient model for the specification and verification of concurrent programs, but has eschewed efficient execution so far. This article shows how guarded atomic actions, when attached to objects, can be implemented highly efficiently using a combination of coroutines, operating-system worker threads, and dedicated management of object queues and stacks. The efficiency of an experimental language, Lime, is shown to compare favourably with that of C/Pthreads, Go, Erlang, Java, and Haskell on synthetic benchmarks.

Paper Structure

This paper contains 6 sections, 2 equations, 11 figures.

Figures (11)

  • Figure 1: Delayed doubler in Lime
  • Figure 2: Possible state of a priority queue after adding 4, 5, 7, 6
  • Figure 3: Priority Queue in Lime
  • Figure 4: Leaf-oriented Tree in Lime
  • Figure 5: Map-reduce in Lime
  • ...and 6 more figures