2022
an archive of posts from this year
-
Creating and managing threads
What does it mean to run several flows of execution? Creating threads with std::thread, managing their lifetime with join/detach, and C++20 jthread with its automatic join and cooperative cancellation.
-
Softmax and Cross-Entropy
Deriving the softmax Jacobian and the cross-entropy gradient, and why their composition collapses into prediction minus target.
-
Interfaces
An interface acts as the contract that governs how objects interact.
-
Mutexes and RAII-based locking
Why does data break when several threads touch it at once? The mutex that prevents race conditions, exception-safe RAII locking (lock_guard and unique_lock), and shared_mutex, which distinguishes reads from writes.
-
condition_variable and synchronisation patterns
How do you put a thread to sleep until a condition holds, and then wake it? The condition_variable that removes busy waiting, why lost and spurious wakeups are prevented, and the producer-consumer work queue.
-
Handling results with future, promise, and async
How do you get back the one result a thread computed? future/promise, which strips away the mutex+cv plumbing, std::async, packaged_task, and exception propagation across thread boundaries.
-
atomic and the memory model
How is sharing without locks possible? std::atomic and CAS, reordering by the compiler and CPU, and the seq_cst, acquire/release, and relaxed memory orderings with happens-before.
-
Networks and layering - why the internet was split into layers
How do you divide up an enormous communication problem? The choice of packet switching, and the layered design that makes each layer answer only for its own job.
-
Concurrency bugs and debugging
Why do concurrency bugs only fire "sometimes"? What deadlocks, data races, and false sharing really are, and how to catch hard-to-reproduce bugs with ThreadSanitizer.
-
The link layer - delivery within one network
How do two devices on the same network find each other? MAC addresses and switches, and ARP, which turns an IP address into a MAC address.
-
The internet layer (IP) - finding the way by address
How do you cross many networks to reach a destination host? IP as a hierarchical address, routing that picks the next step at every hop, and the best-effort design that promises no delivery.
-
The transport layer (TCP/UDP) - reliability is a choice
Who guarantees the reliability IP never promised? Ports that distinguish processes, TCP which builds reliability on top, and UDP which refuses to pay for it.
-
The application layer (DNS/HTTP) - look up a name, then talk
People use names, not IP addresses. DNS, the distributed system that turns names into addresses, and HTTP, the language the web speaks over them.
-
Putting it together - what happens when you type a URL
From pressing Enter to the page appearing, every layer in the series is called on within a second. The final part traces all five as a single flow.