Programming Language Integrated Software Transactional Memory

An exploration of Software-Transactional-Memory (STM) as the main concurrency control mechanism for a minimal programming language.

Initial situation

The development of concurrent programs that access shared data presents a significant challenge and is often prone to errors. The primary issues stem from the need to coordinate access in order to ensure data consistency and proper synchronization. In particular, race conditions, deadlocks, and memory inconsistencies are among the most common difficulties faced by developers. To address the inherent challenges of traditional concurrency synchronization mechanism, alternative models have been proposed, with the aim of reducing both complexity and susceptibility to errors. One such approach is Software Transactional Memory (STM). STM is based on the idea of managing memory transactions in a manner similar to database systems, allowing multiple threads to access shared data concurrently without requiring explicit locking mechanisms.

Problem statement / Project goal

As part of this project, tinylang, a minmal programming language developed in the previous project, was extended with a deeply integrated Software Transactional Memory (STM) system, making STM the central concurrency model and removing the need for traditional synchronization mechanisms such as locks. The work evaluates this integrated approach against a functionally equivalent STM provided as a library, assessing whether deep integration offers substantial benefits or only marginal improvements.
Concretely, this paper aims to answer the following questions:

  • What STM implementation strategies exist, and how well are they suited for deep integration into the previously developed programming language?
  • In which aspects (e.g., performance, developer ergonomics, etc.)—and to what extent—does a language-integrated STM differ from an STM provided as a library?

Concurrent Counter

FHNW

An implementation of a program which modifies shared-memory concurrently safely and without traditional locking mechanisms.

Integration Strategy

FHNW

The STM is implemented through a compiler-defined runtime-interface. This provides great modularity and allows the underlying STM implementation to be swapped out and modified easily, without having to change the compiler.

Concurrent Banking

FHNW

This program demonstrates that the introduced language constructs (such as the atomic block) provide a composable way to safely access and modify shared memory concurrently.

Results

The project extended tinylang with a deeply integrated Software Transactional Memory (STM) system based on the TL2 algorithm, using a runtime interface–based integration strategy. This approach introduced STM constructs such as the atomic keyword and type modifier directly into the language, while keeping the STM logic modular and replaceable. A comparison with an equivalent TL2 library, also developed during this project, showed that deep integration offers qualitative advantages: transactional intent is explicit in the syntax, boilerplate is reduced, and compile-time checks prevent common concurrency errors that the Go library can only detect at runtime. These findings indicate that a runtime interface–based integration is well-suited, and that deep STM integration can enhance correctness, safety, and developer experience, particularly in contexts where clarity and maintainability are valued over low-level optimization.

Key terms

  • CompilerA compiler is a program that translates high-level source code into machine code or an intermediate form executable by a computer.
  • TL2Transactional Locking 2 is a well known STM algorithm which provides similar guarantees to ACID in database systems for concurrent memory access.
  • STMSoftware Transactional Memory is a concurrency control mechanism based on the idea of managing memory transactions in a manner similar to database systems, allowing multiple threads to access shared data concurrently without requiring explicit locking mechanisms.

Team

Lorenzo Baldassarri

Advisors
Daniel Kröni
Markus Knecht