MUTEX
FORK
YIELD
DEADLOCK
SPAWN
RACE
AWAIT
SYNC
LOCK
JOIN
SIGNAL
ATOMIC

Threads don't wait politely

A mutex is a polite fiction. Two threads approach the same resource, and we pretend that one will always step aside. But concurrency is not polite. The scheduler owes no one fairness, and starvation is just patience taken to infinity.

mutex_lock()

The moment you ask for exclusivity, you admit the system cannot be trusted.

contention: 94.7%

Most of your threads are waiting. That's not a bug. That's concurrent reality.

Mutual exclusion

The elegant lie at the heart of concurrent systems. If everyone agreed to take turns, we wouldn't need locks. But nobody agreed.

Thread 0 halted. Thread 1 proceeds. Thread 2 halted. The gaps are where deadlocks hide.

The race nobody wins

Fork

One becomes two. The promise of parallelism. But the child process doesn't know what the parent intended. That's the beauty of it.

A race condition is a haunting. It appears unpredictably. It vanishes when you look directly at it. Your logs say everything was fine. Your users say the account balance went negative. Both statements are true simultaneously, which is, of course, the whole problem.

read(x) -> 7 read(x) -> 7 write(x, 8) write(x, 8)

Two threads. Same read. Same write. One update lost forever. Nobody noticed until production.

Threads converge. Data collides. The race was over before anyone knew it started.

Waiting is a kind of work

A spinlock is the most honest primitive in concurrency. It doesn't pretend to be doing something useful. It sits and checks. Sits and checks. An infinite loop of hope, burning CPU cycles as a sacrifice to the god of eventual availability. The operating system sees a busy thread and smiles knowingly.

Deadlock

Thread A holds lock 1, wants lock 2. Thread B holds lock 2, wants lock 1. They will wait forever. This is not a bug in the code. This is a philosophical statement about desire.

blocked blocked blocked

All threads halted. All resources held. The system is perfectly still, perfectly broken.

Synchronization is faith

The barrier

A barrier says: nobody moves until everyone arrives. It's the most collectivist primitive in a system built on isolation. Every thread suspends its selfishness at the barrier and waits for the slowest among them.

Semaphores count permissions. Not threads, not resources, just abstract units of allowance. A number goes up, a number goes down. The system's health is measured by an integer that most engineers have never directly observed. Trust it. You have no choice.

sem_wait() // hope
sem_post() // relief

Every concurrent system that works is a small miracle of coordination. The threads don't know each other. They share nothing but memory and a fragile contract of ordering guarantees.

All threads have joined. The system rests. What remains is not the work that was done, but the quiet proof that isolated processes, given enough patience and the right primitives, can converge on a shared truth.