|
|
Subscribe / Log in / New account

Lockless patterns: an introduction to compare-and-swap

Lockless patterns: an introduction to compare-and-swap

Posted Mar 14, 2021 9:56 UTC (Sun) by pbonzini (subscriber, #60935)
In reply to: Lockless patterns: an introduction to compare-and-swap by dgc
Parent article: Lockless patterns: an introduction to compare-and-swap

Heh, I doubt you'd learn anything new! I do hope that more experienced people get some insights about how to present abstract concepts and their concrete embodiments at the same time, for example happens-before both as a math relation and as a property of APIs.

There's a chicken-and-egg problem between teaching the "what" and the "when/why". My choice here was to first teach the "what" so that people would be able to read others' code, and leave the "when/why" for the end, but I'm sure it was possible to do it otherwise. I read somewhere that you can't teach something well until the fifth time you teach it.

> I do "scalability" and not "lockless"....

Well, everybody should be doing scalability and not lockless. I focused the series on "lockless patterns" because, again, my aim was to teach people how to deal with code written by others. (Fun fact: I had never seen before the TCP code I explained in part 3. I literally grepped for smp_mb and picked a random example. It's too easy to omit details when explaining code you're familiar with, and I wanted to be in the same shoes as the readers).

But lockless (and sharding :)) are just tools that you use to achieve scalability. If you don't need scalability just throw a big lock around everything and call it a day!


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds