The 13th Floor: How Your Computer Really Works
The Building
๐ฆ Nephew: Uncle, honestly, I feel a little embarrassed saying this - I write code every single day, I ship things to production, but I don't actually know what happens inside the machine when my code runs. Like, genuinely, at the ground level. I want to understand it properly. Not just definitions I can repeat in an interview - I want to actually feel it.
๐จโ๐ฆณ Uncle: That's not embarrassing at all, that's actually the most honest thing a developer can admit. Most people learn to drive a car without ever opening the hood. You've learned to write code without ever opening the laptop, so to speak. So tonight, let's open the hood properly. And I'm not going to rush. If something doesn't click, you stop me and ask, and we sit there until it clicks. Deal?
๐ฆ Nephew: Deal.
๐จโ๐ฆณ Uncle: Good. So here's how I want you to picture it. Forget the laptop for a second. Imagine a big apartment building - say, 13 floors, dozens of flats. Real building, real people living their real lives inside it. Now, in any apartment building like this, what are the things everyone shares, that no single flat owns for themselves?
๐ฆ Nephew: Hmm... water supply, I guess. Electricity. Maybe the lift.
๐จโ๐ฆณ Uncle: Exactly - water, electricity, the internet/cable connection coming in from a tower outside, the lift, maybe a shopping arcade or a small mall on the ground floor where different shops have rented space. Nobody owns the main water tank personally. Nobody owns the electrical transformer. There's a building management office - a facility manager - whose entire job is to take these shared, limited resources and distribute them fairly across every single flat, every single day, without anyone even noticing the effort involved.
๐ฆ Nephew: Okay, I can picture that. So where's the connection to my laptop?
๐จโ๐ฆณ Uncle: Here's the thing - your laptop, right now, sitting in front of you, is exactly this. It has shared, limited resources. It has many "tenants" - your Chrome, your VS Code, your Node app, Spotify, whatever else is running. And it has one facility manager sitting quietly in the background making sure none of them collide, none of them starve, and none of them accidentally shut off water for the whole building. That facility manager has a name: the Operating System. On your machine, that's Ubuntu.
๐ฆ Nephew: Wait - so Ubuntu is literally playing the role of that building manager?
๐จโ๐ฆณ Uncle: Precisely that role, doing precisely that job, every second your laptop is switched on. And tonight, we're going to walk through the building floor by floor, resource by resource, until you can see it as clearly as you'd see the actual water pipes and wiring in a real apartment block.
The Two Basic Resources - Before We Even Talk About the Manager
๐จโ๐ฆณ Uncle: Before we even bring the facility manager into the picture, let's understand the two most basic physical resources in this building. Because if you don't understand why these two exist and why they're different, nothing else after this will make real sense - you'll just be memorizing terms.
๐ฆ Nephew: Okay, I'm listening.
๐จโ๐ฆณ Uncle: So - every apartment building needs two very different kinds of storage space, right? Think about it practically. There's the space where you keep things you use right now, today, within arm's reach - your kitchen counter, your desk. And there's the space where you store things long-term - a storeroom, a locker downstairs, maybe a warehouse if it's a bigger complex.
๐ฆ Nephew: Sure, that makes sense in a normal house too.
๐จโ๐ฆณ Uncle: Right. Now here's the key difference between those two spaces - and I want you to really sit with this, because it explains almost everything else tonight. The kitchen counter is small, but it's instantly reachable. You don't walk anywhere, you just reach out and grab the thing. The storeroom is huge, you can keep years of stuff there, but every single time you need something from it, you have to physically get up, walk there, dig through boxes, and walk back. It's slower, by a lot.
๐ฆ Nephew: Okay...
๐จโ๐ฆณ Uncle: Your laptop has the exact same two spaces, and they have names you already know but maybe never connected to this idea: RAM is the kitchen counter. SSD (your storage drive) is the storeroom.
- SSD โ the storeroom/warehouse. Huge. Permanent - things stay there even if the power goes off. But slow to reach into.
- RAM โ the kitchen counter. Small. Temporary - the moment power is cut, everything on it vanishes, wiped clean. But blazing fast to reach into.
๐ฆ Nephew: Wait, why does RAM lose everything when power goes off? That seems like a strange design. Why not just make one storage that's fast AND permanent?
๐จโ๐ฆณ Uncle: Ah - now you've asked exactly the right question, the one most people never even think to ask. Here's the honest, physical answer: RAM is fast because it's built out of tiny electrical circuits that hold a value only as long as electricity is actively flowing through them - like holding a ball up in the air with your hand. The moment you stop actively holding it up (cut the power), it falls - the value is gone. That's literally why it's so fast: there's no mechanical or chemical process involved, just electricity sitting in a circuit, ready instantly.
An SSD, on the other hand, stores information by physically trapping electrical charge inside tiny cells - a bit like locking a ball inside a small box. That box stays locked even without power, which is why it survives a shutdown. But locking and unlocking that box takes real physical time - more steps, more overhead - which is exactly why it's slower.
๐ฆ Nephew: Oh - so it's genuinely a trade-off. Fast-but-forgetful, or slow-but-permanent. You can't easily get both.
๐จโ๐ฆณ Uncle: That's exactly it, and that trade-off is one of the oldest, most fundamental facts in all of computing. And because RAM is fast, it's also more expensive to manufacture per gigabyte - that's why your laptop probably has 8, 16, maybe 32 GB of RAM, but 512 GB or a full terabyte of SSD storage. You get a lot less of the fast, expensive counter space, and a lot more of the slow, cheap warehouse space. That balance is deliberate, in every computer ever built.
๐ฆ Nephew: Okay, this is already making more sense than any explanation I've read before. So when I actually run my code - say, node index.js - what happens between these two?
๐จโ๐ฆณ Uncle: Good, hold that question - we're about to get there, but properly, step by step, not in a rush. First I want you to fully own this one idea: your code, right now, sitting saved in a file on your laptop, is sitting in the storeroom - the SSD. It's not doing anything. It's just sitting there, dormant, like a recipe written on paper inside a folder in the storeroom. For it to actually run, it has to be pulled out of the storeroom and placed on the kitchen counter - RAM - because only things on the counter can actually be worked with, actively, right now.
๐ฆ Nephew: So "running" a program literally means: copy it from the SSD onto RAM?
๐จโ๐ฆณ Uncle: Essentially, yes - copy the necessary parts onto RAM, and then actively work with it there. And that copying, that whole decision of what goes onto the counter, how much space it gets, who's allowed to use the counter and for how long - none of that happens on its own. Someone has to manage it. And that's exactly where our facility manager, Ubuntu, walks back into the story.
Meet the Facility Manager
๐จโ๐ฆณ Uncle: So picture it again - the building. Ground floor has a small mall with shops. Floors 1 through 13 have flats, some occupied, some empty, tenants moving in and out all the time. Somewhere in the building, there's an office - small, unglamorous, but absolutely critical - where the facility manager sits, watching everything.
THE BUILDING (your laptop's hardware)
CPU workers, RAM counters, SSD storeroom,
shared electricity, water, network tower
โ
โโโโโโโโโโโโดโโโโโโโโโโโ
โ FACILITY MANAGER โ โ Ubuntu, the OS
โ (decides who gets โ
โ what, and when) โ
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โโโโโโฌโโโโโโดโโโโโโฌโโโโโ
โ โ โ โ
Flat 3 Flat 7 Flat 11 Flat 13
(Chrome) (Node app)(Redis) (Spotify)
๐ฆ Nephew: Okay, why does a building even need a facility manager, though? Why can't tenants just... sort it out themselves? Like, why can't my Node app just directly grab RAM whenever it wants?
๐จโ๐ฆณ Uncle: Because imagine what happens without one. Say tenant in Flat 3 decides they want the entire building's electricity for their personal use tonight, and just wires it directly to their flat, bypassing everyone else. What happens to the other twelve floors?
๐ฆ Nephew: Blackout. Everyone else loses power.
๐จโ๐ฆณ Uncle: Exactly. Or imagine two tenants both try to plug into the exact same water pipe outlet at the exact same time, each assuming it's theirs alone. Chaos, leaks, conflicts. So the building enforces one absolute rule: no tenant touches shared infrastructure directly. Every single request - for water, electricity, network access, storeroom access - goes through the facility manager. Always. No exceptions, for anyone.
In computer terms, this has an actual name. The tenants - your applications - live in something called user space. They're not allowed to touch hardware directly. Only the facility manager - the OS - lives in kernel space, the one place with actual direct control over electricity, water, RAM, everything. Whenever your app needs anything from the hardware, it makes a polite, formal request called a system call - literally, knocking on the manager's office door and asking.
Your app:"Could I get a bit of RAM, please?"โโ> Ubuntu (kernel space)
โ
v
Ubuntu actually talks
to the RAM hardware directly
โ
v
Your app:"Thank you, here's my space"<โโโโโโโโโโโโโโโโ
๐ฆ Nephew: So even something as tiny as needing a bit of memory - my app can't just take it, it has to formally ask?
๐จโ๐ฆณ Uncle: Every single time, no matter how small the request. It feels invisible because it happens thousands of times per second and takes microseconds - but structurally, that knock on the door happens, every time. Hold onto this rule tightly, because literally everything else tonight is built on top of it.
A New Tenant Moves In
๐จโ๐ฆณ Uncle: Alright. Let's finally bring in your actual example. You open your terminal, you type:
npm start
You hit Enter. Before anything else happens - just pause there for a second. What do you think is the very first thing that needs to happen, based on everything we've just said?
๐ฆ Nephew: I guess... my code needs to move from the storeroom, the SSD, onto the kitchen counter, the RAM?
๐จโ๐ฆณ Uncle: Very good - you're already thinking in the right direction. But even before that copying happens, there's a step before the step. Ubuntu first has to decide: "Is this a completely new tenant moving into the building, or an existing one?" In this case, it's new. So Ubuntu creates what's called a process - think of it as officially registering a brand-new tenant into a brand-new, empty flat. This tenant gets a unique flat number (in computing, it's called a PID - Process ID), and a private slice of RAM that belongs only to them - nobody else in the building, no other tenant, can see inside it or touch it.
$ npm start
โ
v
Ubuntu: "New tenant moving in. Let's set them up properly."
โ
โโโ Assign a unique PID (like flat number 4521)
โโโ Go to the storeroom (SSD), pull the Node code off the shelf
โโโ Copy it onto a fresh, private RAM counter
โโโ Officially mark this tenant as "now living here, running"
๐ฆ Nephew: Why does it need to be private, though? Why can't two tenants just share the same RAM space if they trust each other?
๐จโ๐ฆณ Uncle: Excellent question - and here's the real-world reasoning. Imagine two tenants shared one open flat with no walls between them. If one tenant's kid accidentally breaks something, it affects the other tenant too, even though they had nothing to do with it. Now translate that to software: if one process could freely read or write into another process's memory, one buggy or crashed program could corrupt or crash a completely unrelated one. Isolation isn't bureaucracy for its own sake - it's what stops one tenant's mess from becoming everybody's problem.
# You can literally see the current tenant list yourself
$ ps aux
USER PID %CPU %MEM COMMAND
you 4521 2.1 1.5 node index.js
you 4522 0.0 1.4 node index.js # a completely separate tenant
๐ฆ Nephew: Oh interesting - so if I ran npm start in two different terminal tabs, I'd actually get two totally separate flats, even though it's literally the same code?
๐จโ๐ฆณ Uncle: Exactly - two separate PIDs, two separate private RAM slices, two independent tenants - even though, ironically, they're running identical code. If one crashes, the other doesn't even notice.
Family Members Sharing One Flat - What's a Thread, Really?
๐ฆ Nephew: Okay wait, before we go further - I keep hearing "threads" thrown around alongside "processes," and honestly I've always just nodded along without really knowing the difference.
๐จโ๐ฆณ Uncle: Fair, let's fix that properly. If a process is one flat, a thread is like a family member living inside that flat. They share the same furniture - the same RAM - but each one can be doing something different, at the same moment, moving around the flat independently.
Process (one flat, one private RAM space)
โ
โโโ Thread 1 - one family member, cooking
โโโ Thread 2 - another family member, cleaning
โโโ Thread 3 - a third, watching TV
All three share the SAME furniture (RAM) - but each is doing
a different task, at the same time, without waiting on the others
๐ฆ Nephew: So a program that's "single-threaded" is like a flat with only one person living there, doing one thing at a time?
Comments
No comments yet. Start the discussion.