# Underrust: What is the cost of Mutex, RwLock and AtomicPtr?

DevFeed: [Underrust: What is the cost of Mutex, RwLock and AtomicPtr?](<https://devfeed.tech/articles/underrust-what-is-the-cost-of-mutex-rwlock-and-atomicptr-35479.md>)

Original publisher: [Read original article](<https://darkcoding.net/software/underrust-mutual-exclusion/>)

Author: Graham King

Published: 2025-05-05T20:05:00Z

Content type: tutorial

Language: en

Sources: [Graham King](<https://devfeed.tech/sources/graham-king.md>)

Topics: [Rust](<https://devfeed.tech/topics/rust.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>), [x86](<https://devfeed.tech/topics/x86.md>), [cpu](<https://devfeed.tech/topics/cpu.md>), [Assembly](<https://devfeed.tech/topics/assembly.md>)

Tags: [assembly](<https://devfeed.tech/tags/assembly.md>), [concurrent](<https://devfeed.tech/tags/concurrent.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [cycles](<https://devfeed.tech/tags/cycles.md>), [locking](<https://devfeed.tech/tags/locking.md>), [performance](<https://devfeed.tech/tags/performance.md>), [rust](<https://devfeed.tech/tags/rust.md>), [software](<https://devfeed.tech/tags/software.md>), [synchronization](<https://devfeed.tech/tags/synchronization.md>), [underrust](<https://devfeed.tech/tags/underrust.md>)

## AI overview

A Rust-focused analysis uses assembly output to examine the cost of Mutex, RwLock, and atomic operations for many concurrent readers and an occasional writer. It scopes the discussion to Linux and x86, noting that the fast-path operations discussed are roughly in the range of 20 to 30 CPU cycles.

## Source excerpt

With many concurrent readers and a single occasional writer, which mutual exclusion primitive should you use? Let's look at the assembly to find out.