Basic Lock Algorithms in Lightweight Thread Environments

📅 2025-12-09
📈 Citations: 0
Influential: 0
📄 PDF

career value

173K/year
🤖 AI Summary
To address deadlock susceptibility and poor adaptability of conventional OS-thread locks in lightweight threading contexts (e.g., coroutines, async tasks), this paper introduces a novel synchronization mechanism tailored for lightweight threads. Methodologically, it (1) enhances TTAS and MCS locks by explicitly integrating yield/sleep semantics to eliminate busy-wait-induced scheduler deadlocks; (2) proposes a hybrid lock combining multi-queue MCS with TTAS to jointly optimize low latency and cross-library compatibility; and (3) implements and validates the design on mainstream C++ coroutine libraries (e.g., libcoro, Boost.Coroutine2). Experimental results demonstrate that the proposed cooperative lock significantly outperforms naively ported traditional locks in throughput, tail latency, and cross-platform stability. This work establishes the first systematic, portable lock design paradigm for lightweight concurrent programming.

Technology Category

Application Category

📝 Abstract
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.
Problem

Research questions and friction points this paper is trying to address.

Designing mutex locks for lightweight thread environments
Adapting TTAS and MCS locks to prevent deadlocks in lightweight threads
Balancing performance across different lightweight thread libraries
Innovation

Methods, ideas, or system contributions that make the work stand out.

Modified TTAS and MCS locks for lightweight threads
Utilized yielding and sleeping context switch mechanisms
Proposed cohort lock balancing MCS and TTAS performance
🔎 Similar Papers
No similar papers found.