# Treating Preemption as Garbage Collection for Memory Reordering in Lock-Free Code

Original title: Preemption is GC for memory reordering (2019)

> Hacker News story 48831814 · language: en · submitted 2026-07-08
> Web version: https://zeli.app/story/48831814
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 8 · by [mpweiher](<https://news.ycombinator.com/user?id=mpweiher>) · 💬 0
[original](<https://pvk.ca/Blog/2019/01/09/preemption-is-gc-for-memory-reordering/>) · [HN discussion](<https://news.ycombinator.com/item?id=48831814>)

## Summary

I argue that we should treat preemption as a sunk cost, similar to garbage collection, to guarantee memory ordering in userspace without explicit barriers. By leveraging the serializing nature of interrupts on x86, we can implement efficient lock-free primitives like event counts and hazard pointers. This approach allows threads to sleep instead of spinning, integrating seamlessly with OS-level blocking while preserving lock-freedom and avoiding the overhead of traditional memory barriers.

## Key quote

> I now believe that preemption ought to be treated as a sunk cost, like garbage collection: we're already paying for it, so we might as well use it.

## HN discussion (0 comments)

### [gblargg](<https://news.ycombinator.com/item?id=48868950>)

> If I understand this correctly, it basically has the second thread wait until the first one experiences a hardware interrupt, which implicitly synchronizes memory. This avoids the first thread from needing any synchronization primitives that would slow it down.

### [Jweb_Guru](<https://news.ycombinator.com/item?id=48868596>)

> Oh boy this is a cool blog post.  Encourage everyone to read it.

### [preetham_rangu](<https://news.ycombinator.com/item?id=48869278>)

> same trick QSBR uses for lock-free reclamation, just framed at the OS scheduler level instead of userspace

---

## Cite

- Page: https://zeli.app/story/48831814
- Date: 2026-07-08
- Source: pvk.ca (https://pvk.ca/Blog/2019/01/09/preemption-is-gc-for-memory-reordering/)
- Hacker News: https://news.ycombinator.com/item?id=48831814

## Other languages

- zh: https://zeli.app/zh/story/48831814 · markdown: https://zeli.app/zh/story/48831814.md
- ja: https://zeli.app/ja/story/48831814 · markdown: https://zeli.app/ja/story/48831814.md
- ko: https://zeli.app/ko/story/48831814 · markdown: https://zeli.app/ko/story/48831814.md
- de: https://zeli.app/de/story/48831814 · markdown: https://zeli.app/de/story/48831814.md
- es: https://zeli.app/es/story/48831814 · markdown: https://zeli.app/es/story/48831814.md
