{
  "version": "https://jsonfeed.org/version/1",
  "title": "Ian's Digital Garden",
  "home_page_url": "https://ianwwagner.com/",
  "feed_url": "https://ianwwagner.com//tag-podcasts.json",
  "description": "",
  "items": [
    {
      "id": "https://ianwwagner.com//sequence-locks.html",
      "url": "https://ianwwagner.com//sequence-locks.html",
      "title": "Sequence Locks",
      "content_html": "<p>I just listened to a fantastic Two's Complement <a href=\"https://www.twoscomplement.org/podcast/sequence_locks.mp3\">podcast episode</a>\n(<a href=\"https://www.twoscomplement.org/podcast/sequence_locks.txt\">transcript</a>)\nin which Matt and Ben discussed a data structure I'd never heard of before:\nthe <a href=\"https://en.wikipedia.org/wiki/Seqlock\">sequence lock</a>.\nIt is not very well known,\nbut it's useful for cases where you want to avoid writer starvation\nand it's acceptable for readers to do a bit more work\n(and occasionally fail).</p>\n<p>Some use cases they discussed:</p>\n<ul>\n<li>Getting the time information from the kernel without a syscall</li>\n<li>Getting the latest stock ticker price when latency isn't a concern</li>\n</ul>\n<p>The basic idea is to increment an atomic variable two times:\nonce when a writer enters the critical section, and again when it is finished.\nThis clever dance lets readers quickly check that they aren't reading in the middle of an update,\nsince a simple modulo 2 check will tell you if you're reading during an update.\nClever!</p>\n<p>It's a lot lighter than a mutex,\nallows a single writer in the basic case,\nbut can support more (per Matt).\nAnd of course there is no mutex or similar mechanism creating a bottleneck.</p>\n<p>The tradeoff is that reads can fail,\nand it is the responsibility of the reader to retry in this case.\nReaders will always be able to get the latest value <em>eventually</em>,\nand writers are never blocked.</p>\n<p>During the podcast, Matt mentioned formal verification in passing,\nsince it's difficult to gain confidence in these sorts of things.\nThis area is something I've long been fascinated with,\nbut agree with him that it's not practical for most applications.\nIf formal verification is interesting to you,\nOxide &amp; Friends did a whole <a href=\"https://oxide-and-friends.transistor.fm/episodes/software-verificationpalooza\">episode on it</a>.</p>\n",
      "summary": "",
      "date_published": "2024-10-30T00:00:00-00:00",
      "image": "",
      "authors": [
        {
          "name": "Ian Wagner",
          "url": "https://fosstodon.org/@ianthetechie",
          "avatar": "media/avi.jpeg"
        }
      ],
      "tags": [
        "concurrency",
        "data-structures",
        "podcasts"
      ],
      "language": "en"
    }
  ]
}