Ближайшая конференция — JPoint 2025, 3–4 апреля (Москва + трансляция).
Подробности и билеты: https://jrg.su/T2zfbS
— —
. . . . Kotlin is a modern and pragmatic language, developed by JetBrains, that compiles to Java Virtual Machine (JVM). Kotlin 1.1 introduced coroutines for writing scalable asynchronous code. Basically, Kotlin coroutines are very light-weight threads, and millions of concurrent coroutines can be easily running, each coroutine occupying just a few dozen bytes of the heap when suspended. Because of the inherent scalability requirement, many concurrent data structures used in the coroutines, such as communication channels between coroutines, are expected to be lock-free and disjoint-access parallel, yet they have to be practical and readily implementable in the confines of JVM. This creates unique challenges for the design of the corresponding support libraries.
In this lecture we shall walk through the basics of lock-free doubly-linked lists by Sundell & Tsigas and multi-word compare-and-swap (CASN) by Harris - two practical lock-free constructions that serve as a backbone for many lock-free algorithms in Kotlin coroutines support libraries. We'll discuss challenges of designing linearisable implementations for complex data structures and how to extend CASN to support limited, but practically needed combinations of several operations on different data structures in the form of atomic transactions, without going into full-blow implementation of general-purpose software transactional memory.