Application Binary Interface from the Ground Up

ABI [https://en.wikipedia.org/wiki/Application_binary_interface] stands for Application Binary Interface. It includes a set of rules e.g. calling conventions. For a long time, I found the concept of ABI hard to grasp. I want to take a step back and see if we start from…

Fix Flickering Relay Switch caused by Nest Thermostat

About one month ago I noticed one relay switch was flickering from time to time at the zone control board. Narrow it down The first step of debugging is to narrow the potential problem area down. Like any interesting (annoying) bugs, the problem doesn't happen all the time. So I…

`struct Foo f;` and `struct Foo f{};` are very different

Compare the following two programs, and can you predict what the outputs would be for each? // program #1 struct Foo { int x; }; void stack() { int x = 3; } void bar() { struct Foo foo{}; cout << foo.x << endl; } int main() { stack(); bar(); return 0; } // program #2 struct Foo { int x; }; void stack(…

Learning C++ Memory Model from a Distributed System's Perspective

If C++ standard were reworded using distributed system terms, it might be more readable. Your single machine is actually a distributed system in disguise Multiple cachelines inside your multi-core machine make a distributed system. Cacheline coherence is 100% a distributed system problem. C++ tries to provide a high level abstraction…

Fiber-compatible Future

folly [https://github.com/facebook/folly]'s Future API is Fiber-compatible. > Calling get() on a folly::Future object will only suspend the calling fiber-task. It won't block the system thread, letting it process other tasks. – https://github.com/facebook/folly/blob/master/folly/fibers/README.md But how does it…

DNS – the first distributed database

DNS was created in 1983. Before then, Stanford was storing the host name to IP address map on HOSTS.TXT, which obviously doesn't scale. DNS is the address book of the internet, which performs a simple function of translating domains to IP addresses. One way of looking at it is…

There's Nothing 100% in Computer Science

When it comes to correctness guarantees, there are few communities in Computer Science (software) more obsessed with them than the database and distributed system communities. They better be serious about correctness because everyone's bank account balances depend on it. You have heard about terms like Paxos, consensus, fault tolerance, but…

When would someone use std::enable_shared_from_this

std::enable_shared_from_this [https://en.cppreference.com/w/cpp/memory/enable_shared_from_this] allows a class to have a valid shared_ptr of this. Simply adding a member function that returns shared_ptr(this) is susceptible to double-free. But when would you use such a feature?…