Basic Lock Algorithms in Lightweight Thread Environments

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Skazhenik, Taras, Korobenikov, Nikolai, Churbanov, Andrei, Malakhov, Anton, Aksenov, Vitaly
Format: Preprint
Veröffentlicht: 2025
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866911310241857536
author Skazhenik, Taras
Korobenikov, Nikolai
Churbanov, Andrei
Malakhov, Anton
Aksenov, Vitaly
author_facet Skazhenik, Taras
Korobenikov, Nikolai
Churbanov, Andrei
Malakhov, Anton
Aksenov, Vitaly
contents Traditionally, multithreaded data structures have been designed for access by the threads of Operating Systems (OS). However, implementations for access by programmable alternatives known as lightweight threads (also referred to as asynchronous calls or coroutines) have not been thoroughly studied. The main advantage of lightweight threads is their significantly lower overhead during launch and context switching. However, this comes at a cost: to achieve proper parallelism, context switches must be manually invoked in the code; without these switches, new lightweight threads will never be executed. In this paper, we focus on the simplest multithreaded data structure: a mutex (also known as a lock). We demonstrate that original implementations for OS threads cannot be used effectively in this new context due to the potential for deadlocks. Furthermore, correctness is not the only concern. In certain languages, such as C++, there are various lightweight thread libraries, each with different implementations and interfaces, which necessitate distinct lock implementations. In this work, we present a modification of TTAS and MCS locks for the use from lightweight threads and demonstrate that the two context switch mechanisms of lightweight threads, yielding and sleeping, are crucial. However, the performance of TTAS and MCS may differ significantly depending on the settings. If one wants to have a lock that works well for any library, we suggest using the cohort lock, which strikes a balance between MCS and TTAS by utilizing several MCS queues with a common TTAS.
format Preprint
id arxiv_https___arxiv_org_abs_2512_08563
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Basic Lock Algorithms in Lightweight Thread Environments
Skazhenik, Taras
Korobenikov, Nikolai
Churbanov, Andrei
Malakhov, Anton
Aksenov, Vitaly
Distributed, Parallel, and Cluster Computing
Traditionally, multithreaded data structures have been designed for access by the threads of Operating Systems (OS). However, implementations for access by programmable alternatives known as lightweight threads (also referred to as asynchronous calls or coroutines) have not been thoroughly studied. The main advantage of lightweight threads is their significantly lower overhead during launch and context switching. However, this comes at a cost: to achieve proper parallelism, context switches must be manually invoked in the code; without these switches, new lightweight threads will never be executed. In this paper, we focus on the simplest multithreaded data structure: a mutex (also known as a lock). We demonstrate that original implementations for OS threads cannot be used effectively in this new context due to the potential for deadlocks. Furthermore, correctness is not the only concern. In certain languages, such as C++, there are various lightweight thread libraries, each with different implementations and interfaces, which necessitate distinct lock implementations. In this work, we present a modification of TTAS and MCS locks for the use from lightweight threads and demonstrate that the two context switch mechanisms of lightweight threads, yielding and sleeping, are crucial. However, the performance of TTAS and MCS may differ significantly depending on the settings. If one wants to have a lock that works well for any library, we suggest using the cohort lock, which strikes a balance between MCS and TTAS by utilizing several MCS queues with a common TTAS.
title Basic Lock Algorithms in Lightweight Thread Environments
topic Distributed, Parallel, and Cluster Computing
url https://arxiv.org/abs/2512.08563