Jump to ratings and reviews
Rate this book

Rust Atomics and Locks: Low-Level Concurrency in Practice

Rate this book
The Rust programming language is extremely well suited for concurrency, and its ecosystem has many libraries that include lots of concurrent data structures, locks, and more. But implementing those structures correctly can be difficult. Even in the most well-used libraries, memory ordering bugs are not uncommon.

In this practical book, Mara Bos, team lead of the Rust library team, helps Rust programmers of all levels gain a clear understanding of low-level concurrency. You’ll learn everything about atomics and memory ordering and how they're combined with basic operating system APIs to build common primitives like mutexes and condition variables. Once you’re done, you’ll have a firm grasp of how Rust’s memory model, the processor, and the role of the operating system all fit together.

With this guide, you’ll learn:

How Rust's type system works exceptionally well for programming concurrency correctly
All about mutexes, condition variables, atomics, and memory ordering
What happens in practice with atomic operations on Intel and ARM processors
How locks are implemented with support from the operating system
How to write correct code that includes concurrency, atomics, and locks
How to build your own locking and synchronization primitives correctly

250 pages, Paperback

Published January 24, 2023

104 people are currently reading
342 people want to read

About the author

Mara Bos

1 book14 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
98 (83%)
4 stars
18 (15%)
3 stars
2 (1%)
2 stars
0 (0%)
1 star
0 (0%)
Displaying 1 - 12 of 12 reviews
Profile Image for Bugzmanov.
233 reviews97 followers
January 11, 2023
This book is short and surprisingly deep. Great combo. Chapter 3 (Memory Ordering) and Chapter 7 (Understanding the Processor) are the gems of the book. This is one of the best introductions of why concurrency is hard from theoretical perspective and how it looks like on a hardware level.

The books is clearly written and very easy to read. I think if you have basic understanding of rust (i.e. finished first half of the rust book) - you are good to read it.
The book takes this clean approach of introducing naive way of building locks and then gradually making it more and more realistic and performant, while explaining all complexities but also tools available for a developer to mitigate them

If chapter 10 (Ideas and Inspiration) made your appetite going here is the list of resources that you might like:
* https://www.goodreads.com/book/show/1...
* https://www.goodreads.com/book/show/1...
* https://www.goodreads.com/book/show/5... (this one is about GC-powered environments)
* https://research.swtch.com/mm (memory models: hardware, theory, practice)
* https://www.youtube.com/watch?v=7OpCf... (why locks in GO are super fast & efficient)
Profile Image for Leandro.
16 reviews1 follower
December 21, 2022
Excellent book for understanding low-level concurrency for Rust or any other language, as the concepts apply for all.

Highly recommended.
4 reviews3 followers
March 8, 2023
For me, Rust Atomics and Locks strikes the perfect balance between depth and breadth.
It is the 'right amount of technical' to keep me engaged.

Mara uses a language that is simple enough for us non-native speakers but not overly simplistic.
It is written in a non-overbearing way, so it felt like a smart friend explaining concurrency internals rather than a detached scholarly dissertation.

I highly enjoyed the book and it sets the bar pretty high for both technical books in general and Mara's next endeavors :)
6 reviews
May 1, 2025
best explanation of c++ memory model that I've seen
Profile Image for Peter Aronson.
397 reviews18 followers
December 9, 2024
An excellently written, concise book on concurrency in any reasonably low-level language, not just Rust. It is written with all examples being Rust, and from a Rust point of view, so some familiarity with Rust and its ecosystem is helpful, but not vital. As noted by other reviewers, the chapters on Memory Ordering and Processors are the real gems (although there are no bad or wasted chapters here).
Profile Image for Santiago Fraire Willemoës.
68 reviews4 followers
April 30, 2023
Really good book that helped me bring concurrency down to earth. Well explained and full of examples. The only thing I would add is a bit more about intuition, for example, a way to identify how many threads are needed for a solution and under which scenarios threads make sense (notice my lack of experience with threads).
Profile Image for Scott Sargent.
15 reviews
April 28, 2024
Absolutely loved this book. One of the few tech books I’ve read cover to cover. Mara brilliantly walks the reader through the complex topics of locking and atomics in rust. If dare say this will make my Go a d Kotlin programming better too.
Profile Image for Craig Rodrigues.
5 reviews1 follower
October 9, 2024
This book is excellent and very well written. It explains in depth, atomic data structures and concurrency in Rust.
108 reviews1 follower
May 11, 2025
太棒了!为 rust 并发编程造轮子,且循序渐进地进行系统优化,明白了各个结构背后实现的原因。
Displaying 1 - 12 of 12 reviews

Can't find what you're looking for?

Get help and learn more about the design.