All posts

concurrency

8 posts
PERFORMANCE

False Sharing: The Cache Line That Kills Your Parallelism

You split work across eight threads with zero shared state, and it runs slower than one thread. The culprit is false sharing — independent variables that happen to live on the same cache line, fighting over it.

CONCURRENCY

Memory Barriers: What volatile Won't Do For You

C's volatile keyword is the most misunderstood tool in concurrent programming. It stops the compiler from caching a value — but it does nothing about the reordering that actually breaks your lock-free code.

DATABASES

MVCC: How Databases Let Readers and Writers Ignore Each Other

Postgres never updates a row — it writes a new version and lets old transactions keep seeing the old one. Multiversion concurrency is why reads don't block writes, why VACUUM exists, and why 'the database is bloated' is a real sentence.

CONCURRENCY

Deadlocks: The Four Conditions and the One Fix That Works

Every deadlock requires four conditions to hold simultaneously, and every practical cure breaks exactly one of them. Why lock ordering is the fix that survives contact with real codebases, and how to find the cycle when it happens anyway.

LINUX

Unix Signals: The API Everyone Uses and Nobody Uses Safely

Signals interrupt your program between any two instructions and run your handler in the wreckage. Why almost everything is illegal inside a handler, what async-signal-safe really means, and the self-pipe/signalfd escape hatches.

EMBEDDED

RTOS vs Bare Metal: When a Microcontroller Needs a Scheduler

A superloop is the right architecture more often than embedded tutorials admit — until the day it isn't, and you need preemption, priorities, and blocking. What FreeRTOS actually buys you on an ESP32, and what it costs.

CONCURRENCY

Spinlocks vs Mutexes: When Burning CPU Is the Right Call

One lock burns CPU while it waits; the other pays a syscall to sleep. The right choice depends on hold time versus context-switch cost — and the best answer, futexes and adaptive locks, is 'both, in that order'.

SYSTEMS

Ring Buffers: The Data Structure at Every Fast Boundary

NIC queues, io_uring, audio pipelines, logging, SPSC channels — wherever a fast producer meets a consumer on a budget, there's a fixed array with two indices. The design decisions that matter: power-of-two sizing, the full/empty problem, and who waits.