Latest / Appropriate Proper Reasonable / 246: Concepts of Operating Systems
Transcript
- 0:00You know, you are probably listening to this
- 0:02deep dive right now on, well, a beautifully sleek
- 0:06piece of glass and metal. Maybe it's a smartphone,
- 0:09maybe a laptop. And when you look at that screen,
- 0:11everything just, you know, it just makes sense.
- 0:13Right. It's very polished. Exactly. It's organized.
- 0:16It's clean. You tap a glowing icon and an app
- 0:20opens smoothly. But underneath that shiny surface,
- 0:23beneath the glass, it is absolute microscopic
- 0:27chaos. Oh. Complete chaos. We're talking billions
- 0:30of transistors firing, electrical currents wildly
- 0:33surging, microscopic hardware components just
- 0:36screaming at each other in completely different
- 0:38languages. It is a messy, ugly reality. The physical
- 0:42reality of computing is entirely chaotic. But
- 0:46you, you know, as the user, you never actually
- 0:48see that chaos, and that is by meticulous design.
- 0:51Which brings us to our mission for today. We
- 0:54are going to peek behind the curtain of the devices
- 0:57we stare at all day long. We really want to demystify
- 1:01the invisible wizard that is actually running
- 1:04the show. Yeah, the wizard behind the curtain.
- 1:06Right. We're going to help you understand how
- 1:07your computer actually works on a foundational
- 1:10level without drowning you in technical jargon.
- 1:13Which is a fantastic goal, honestly. Once you
- 1:16see how the underlying system actually operates,
- 1:18you realize it is one of the greatest magic tricks
- 1:21of modern engineering. It really is. And to help
- 1:23us pull back this curtain, Our source material
- 1:26today is a fascinating post from February 2026.
- 1:30It's titled, Concepts of Operating Systems. That's
- 1:34a great piece. Yeah. It was written by Dr. Gary
- 1:36Ackerman over at hackscience .education for his
- 1:40community college students, which means it is
- 1:43perfect for breaking down incredibly dense concepts
- 1:46into clear, digestible ideas. It's a brilliant
- 1:50synthesis. The text manages to take this vast,
- 1:54intimidating subject and just, well, distill
- 1:57it down to its absolute core principles. Okay,
- 2:00let's unpack this. At its very foundation, an
- 2:04operating system, or OS, basically serves two
- 2:07massive purposes. First, it acts as an extended
- 2:12machine. Right, the illusion. Exactly. Its job
- 2:15is to completely hide all that ugly, messy hardware
- 2:18we just talked about and present the software
- 2:20programs with beautiful, clean, consistent abstractions.
- 2:24And second, it acts as a resource manager. It
- 2:28brings order to the chaos by efficiently and
- 2:31securely multiplexing all that physical hardware
- 2:33among multiple competing programs and users.
- 2:36And to speak directly to you, the listener, for
- 2:39a second here, without this essential layer of
- 2:41software, you wouldn't even be able to play this
- 2:43audio right now. Really? Not a chance. I mean,
- 2:46if application programmers, the people who write
- 2:48your podcast apps, your web browsers, your video
- 2:50games, if they had to understand the intricate
- 2:53microscopic details and electrical quirks of
- 2:56how every single hardware component works, they
- 2:59would be so bogged down that no software would
- 3:01ever get written. They'd just be reinventing
- 3:03the wheel every time. Exactly. The operating
- 3:07system handles all the heavy lifting, so the
- 3:09apps can just, you know, do their jobs. So since
- 3:11the operating system's primary job is managing
- 3:14chaos, I feel like we have to look at the most
- 3:16chaotic scenario of all. Which is running dozens
- 3:19of applications at the exact same time. Right.
- 3:22Think about your own computer right now. You
- 3:24might have a browser open with 50 tabs, music
- 3:27playing in the background, a text message popping
- 3:29up on the screen, and a document quietly saving
- 3:32itself. A very standard setup. Yeah. How does
- 3:36the system not just immediately collapse under
- 3:38the weight of all those simultaneous demands?
- 3:40Well, that brings us to the most central concept
- 3:42in any operating system, which is the process.
- 3:45A process is essentially an abstraction of a
- 3:47running program. Okay, an abstraction. Yeah,
- 3:51but it's not just the static code sitting on
- 3:53your hard drive. A process encompasses everything
- 3:56that program needs to actively run in this exact
- 3:58moment. It includes the memory it's currently
- 4:00using, the registers inside the processor, the
- 4:04program counter that tracks exactly which line
- 4:06of code it's on, and its overall current status.
- 4:09So the process is basically the living, breathing,
- 4:13actively working version of the app. That's a
- 4:15great way to put it, yeah. In a modern system,
- 4:19you have dozens or even hundreds of these processes
- 4:21running. But a CPU, the central processing unit,
- 4:24the actual brain of the computer, can only really
- 4:27do one single calculation at a time per core.
- 4:30Wait, really? Just one. Just one. So the operating
- 4:33system uses a scheduling algorithm. It rapidly
- 4:36switches the CPU back and forth between multiple
- 4:39processes so incredibly fast that it gives you
- 4:41the illusion that dozens of programs are running
- 4:44simultaneously in parallel. OK, that makes me
- 4:46think of a single, highly caffeinated, hyperactive
- 4:51chef running between 10 different stoves. I like
- 4:54that. Right? So the chef, the CPU, chops a carrot
- 4:56at stove one, sprints to stove two to stir a
- 4:59pot of soup, runs to stove three to flip a pancake,
- 5:02and just keeps cycling through all 10 stoves
- 5:04so fast that from the dining room, it looks like
- 5:0810 chefs are cooking 10 separate meals all at
- 5:10once. That perfectly captures the illusion. But
- 5:13you know, the crucial mechanism making that chef
- 5:15analogy actually work? is memory. I mean, think
- 5:19about it. How does a chef switching between 10
- 5:21stoves remember exactly where they left off at
- 5:24each station? Oh, true. Did they already salt
- 5:26the soup? Right. Right. Did they just turn the
- 5:28heat down on the pancake? If they forget, the
- 5:30meals are completely ruined. So the chef needs
- 5:33a perfect memory of every single station's exact
- 5:35state before stepping away. Yes. And in a computer,
- 5:39that perfect memory is called the process table.
- 5:41Process table. OK. When the operating system
- 5:44needs to suspend a process, when it forcefully
- 5:47pulls the chef away from the stove, it grabs
- 5:49all of that process's vital information. The
- 5:52program counter, the registers, the memory map.
- 5:55It saves all of it into an internal OS structure
- 5:58called the process table. So it's basically a
- 6:00snapshot. Exactly. That ensures that when the
- 6:03process is eventually restarted, even if it's
- 6:05just a fraction of a second later, it picks up
- 6:07from the exact microsecond state it was in before
- 6:10it was stopped. Nothing is lost. And processes
- 6:12can even spawn their own child processes, creating
- 6:15this deeply complex hierarchical tree of execution.
- 6:18OK, but we're talking about managing completely
- 6:21separate applications there. What about the multitasking
- 6:24happening inside a single application? The source
- 6:27text dives into something called threads, which
- 6:28seem to operate differently than processes. They
- 6:32do. Threads are fascinating because they solve
- 6:34a major inefficiency. If a process is the whole
- 6:37kitchen stove, Threads are like lightweight mini
- 6:41-processes running within that single process.
- 6:43Mini -processes. Right. The key difference here
- 6:46is isolation. Different processes are completely
- 6:49walled off from each other. Your web browser
- 6:51cannot look at your calculator's memory. But
- 6:53multiple threads within the same process share
- 6:56the exact same address space. They share the
- 6:58same global variables, the same open files. Let's
- 7:01ground this with the word processor example from
- 7:03the text, because I think it makes this highly
- 7:05relatable. Good idea. When you are typing a document,
- 7:08there isn't just one monolithic thing happening.
- 7:11One thread is dedicated entirely to handling
- 7:13your keyboard input, catching every single keystroke.
- 7:16Meanwhile, a second thread is instantly reformatting
- 7:19the document, adjusting the margins and page
- 7:21breaks based on what you just typed. Right. And
- 7:24a third thread is quietly running in the background,
- 7:26saving a backup to your disk every few minutes
- 7:28so you don't lose your work. Exactly. All three
- 7:31of those threads are working cooperatively within
- 7:33the same process. Because they share the exact
- 7:36same document data in memory, the keyboard thread
- 7:39doesn't have to, like, send messages to the formatting
- 7:41thread. They just look at the same data. It's
- 7:44an incredibly efficient, lightweight way to handle
- 7:46complex applications. But this introduces a massive
- 7:49physical constraint, doesn't it? I mean, if we
- 7:51have 100 processes and each of those processes
- 7:55has multiple threads all running at the exact
- 7:57same time, they need space to operate. They need
- 8:00counter space in the kitchen. Oh, absolutely.
- 8:03Where do all these processes live in the hardware
- 8:05without constantly crashing into each other's
- 8:08data? Well, this is the crucial job of memory
- 8:10management. Every computer has main memory, also
- 8:13known as RAM. This is the fast memory that holds
- 8:16the currently executing programs. To keep programs
- 8:19from interfering with one another, the operating
- 8:21system gives each one an abstraction called an
- 8:25address space. An address space. Yes. An address
- 8:28space is a very strict list of memory locations
- 8:31ranging from zero up to some maximum limit that
- 8:34a specific process is exclusively allowed to
- 8:37read and write. So it's like a protective fence.
- 8:40It guarantees that the music player can't accidentally
- 8:43overwrite the memory being used by your email
- 8:45client. Precisely that. The UAS maps this abstract
- 8:49address space onto the actual physical RAM chips.
- 8:53Here's where I get genuinely confused, though.
- 8:55I know my laptop only has a fixed amount of physical
- 8:58RAM. Let's say it's 16 gigabytes. Pretty standard.
- 9:01Yeah. So if I'm a power user and I open a massive
- 9:04video editing project, 50 browser tabs, and a
- 9:07bunch of other heavy programs, I am definitely
- 9:09exceeding that 16 gigabytes of physical space.
- 9:13Why doesn't my computer just completely freeze
- 9:15up, throw an error message, and fail? What's
- 9:18fascinating here is... What's fascinating? Because
- 9:20the operating system lies to the programs to
- 9:23keep the illusion alive. It lies? Oh, constantly.
- 9:27It uses an incredibly elegant mechanism called
- 9:30virtual memory. Virtual memory completely decouples
- 9:33a process's address space from the machine's
- 9:36actual physical RAM. Decoupling them. Wait, so
- 9:39the program doesn't even know where it actually
- 9:41lives? The program has absolutely no idea. The
- 9:45OS gives every single program the illusion that
- 9:48it has a massive, contiguous block of RAM all
- 9:51to itself, even if the physical RAM is completely
- 9:54full. Behind the scenes, the OS acts like a brilliant
- 9:58juggler. Okay, I'm picturing a juggler. It monitors
- 10:01what you are actually doing in real time. It
- 10:04keeps only the most heavily used, actively needed
- 10:06parts of the programs in the fast, main physical
- 10:09memory. And what happens to the rest of it? Like,
- 10:12the browser tab I haven't looked at in three
- 10:14hours. The operating system quietly shuttles
- 10:17all of that inactive data out of the RAM and
- 10:19stores it temporarily on your hard disk. It's
- 10:22called paging or swapping. Wow. So it's basically
- 10:25using the hard drive as overflow parking for
- 10:28the RAM. That is the perfect way to visualize
- 10:31it. And when you finally click back to that old
- 10:33browser tab you haven't viewed in hours, the
- 10:35OS intercepts that request. It quickly shuttles
- 10:38something else out of RAM to the disk to make
- 10:40room and pulls your tab's data from the overflow
- 10:42parking back into the main memory. That's incredible.
- 10:46Yeah. It rapidly shuttles these pieces back and
- 10:49forth as needed entirely invisibly to you and
- 10:52invisibly to the programs themselves. OK, so
- 10:54we've solved how programs talk to the RAM, but
- 10:58virtual memory is just temporary overflow. When
- 11:00you pull the plug or restart the computer, everything
- 11:03in RAM vanishes. How does the OS build a permanent
- 11:06home for this data so you don't lose everything
- 11:09when the power turns off? Well, just like it
- 11:11abstracted the RAM into address spaces, the OS
- 11:15abstracts permanent physical storage into files.
- 11:18Files, right. Data on a hard disk is physically
- 11:21stored as magnetic states on rapidly spinning
- 11:23metal platters or as, you know, trapped electrical
- 11:26charges and solid state flash memory. It is highly
- 11:29complex to read and write to those specific physical
- 11:32sectors. I can imagine. So the OS completely
- 11:35shields the user and the programmer from those
- 11:37messy physical details by presenting a simple,
- 11:40clean abstraction, which is the file. And to
- 11:43keep millions of these files from turning into
- 11:45a disorganized nightmare, The OS uses directories,
- 11:48or what we usually call folders. It organizes
- 11:51them into a huge hierarchical tree structure.
- 11:54Right, the directory tree. Yeah. The source text
- 11:56highlights that files within this tree are identified
- 11:59by their path name. And this is actually pretty
- 12:02intuitive. You can use an absolute path, which
- 12:05is like giving someone driving directions, starting
- 12:07all the way from the root of the drive, saying,
- 12:09you know, start at the C drive, go to users,
- 12:11go to documents, open the file. Exactly. Or you
- 12:14can use a relative path, which is just giving
- 12:16directions starting from whatever folder you
- 12:17are currently sitting in. And if we look at the
- 12:20bigger picture, particularly in Unix based systems
- 12:22like Mac OS or Linux, this file concept is taken
- 12:26to a brilliant extreme. In Unix, almost everything
- 12:30is treated as a file. Everything. Almost everything.
- 12:33The philosophy is that you shouldn't need a different
- 12:35set of tools for every different type of hardware.
- 12:39Hold on. Treating a piece of hardware like a
- 12:41file. Sounds elegant on paper, but physically
- 12:44it makes no sense. I mean, I can't double -click
- 12:47my printer and save a folder inside it. What
- 12:49does it actually mean to treat a printer or a
- 12:52keyboard as a file? It means the OS uses what
- 12:55are called special files to intercept standard
- 12:58file operations. When a programmer writes a piece
- 13:01of software, they use standard commands like
- 13:03open, write, and close to deal with normal text
- 13:05documents. Sure. Well, in Unix, they can use
- 13:08those exact same commands to send data to a printer.
- 13:11The program simply says, write this text to the
- 13:14printer's special file. The program thinks it's
- 13:17just saving a document, but the OS intercepts
- 13:20that write command and redirects the data out
- 13:23through the physical port to the hardware. Wow.
- 13:26That makes the Operati system the ultimate universal
- 13:30translator. Actually, this perfectly explains
- 13:33device drivers. Oh, absolutely. Because we have
- 13:37all these application programmers who just want
- 13:39to speak their one standard language. They just
- 13:42want to use the command print. But there are
- 13:44thousands of different printers in the world
- 13:46built by dozens of different companies all with
- 13:49completely different mechanical quirks and low
- 13:51level mechanics. It would be a nightmare to code
- 13:53for all of them. So the device driver sits in
- 13:55the middle like a translator at the United Nations.
- 13:58Exactly. The programmer says print in their standard
- 14:01language. The OS hands that to the driver. and
- 14:04the driver translates that standard command into
- 14:06the highly specific, intricate mechanical instructions
- 14:10needed to physically move the ink cartridges
- 14:12on that exact model of printer. You've got it.
- 14:15Okay. The device driver understands the low -level
- 14:17physical mechanics of the specific hardware controller.
- 14:20Thanks to that UN translator, the app developers
- 14:23never have to write custom code for every single
- 14:25new brand of hard driver printer that gets released.
- 14:28They just talk to the OS. That saves so much
- 14:31time. Huge amounts of time. And Unix extends
- 14:34this flexibility even further. It has a system
- 14:37call named mount. This allows you to take a removable
- 14:40USB drive, which has its own separate file system,
- 14:43and seamlessly graft it onto a branch of your
- 14:46computer's main directory tree. So to the user,
- 14:49it just looks like another folder appeared. Precisely.
- 14:51Unix also uses pipes, which are pseudo files
- 14:54that let you connect two completely different
- 14:56processes together. The output of the first process
- 14:58flows directly into the pipe and becomes the
- 15:01immediate input for the second process, creating
- 15:03a modular, highly flexible workflow. Okay, so
- 15:06we've got memory swapping, we've got files, we've
- 15:09got universal translators for external hardware.
- 15:12We are looking at a massive, highly complex digital
- 15:16city with a lot of traffic. But... If the OS
- 15:19is providing this universal access to files and
- 15:22raw hardware, we have a massive vulnerability.
- 15:25We do. How does the OS stop a malicious program
- 15:29or just a poorly written one from reaching out
- 15:31and formatting my entire hard drive? How does
- 15:34it enforce order? Security is paramount. Because
- 15:38computers house vast amounts of confidential
- 15:40information and critical system files, the OS
- 15:43has to act as a strict bouncer. It manages exactly
- 15:46who can do what by assigning very strict ownership
- 15:49and access permissions. In Unix, every authorized
- 15:53user is assigned a unique user ID or UID. And
- 15:57every single process that runs, runs carrying
- 16:00the UID of the person who started it. So the
- 16:03process carries your digital ID badge with it
- 16:06everywhere it goes? Yes. And the files themselves
- 16:09are protected by a specific 9 -bit binary code.
- 16:12Nine bits, okay. This code dictates three types
- 16:15of permissions. Read, write, and execute. And
- 16:18it splits those three permissions across three
- 16:21distinct categories. What the owner of the file
- 16:23can do, what the owner's designated group can
- 16:26do, and what everyone else on the system is allowed
- 16:28to do. It provides a very granular level of control.
- 16:32Okay, I understand the badge and I understand
- 16:34the rule book, but here's where it gets really
- 16:37interesting. How does the OS physically enforce
- 16:41that? If a malicious app wants to read my private
- 16:43files, what physically stops it from just reaching
- 16:47into the hard drive and grabbing the data? It
- 16:49enforces the rules at the exact moment the program
- 16:51tries to cross the border. Whenever an app wants
- 16:54to read a file or allocate memory or talk to
- 16:57the printer, it cannot just reach out and do
- 17:00it. It has no physical access to the hardware.
- 17:02It is forced to execute something called a system
- 17:05call. A system call. So it basically has to politely
- 17:08ask the OS for permission. More than just asking,
- 17:12it triggers a fundamental shift in the processor
- 17:14itself. Normally, your web browser or video game
- 17:17runs in what's called user mode. User mode is
- 17:20highly restricted. The CPU physically will not
- 17:22allow user mode programs to interact with hardware.
- 17:25But when your program needs the OS to do something,
- 17:28the system call triggers a trap instruction.
- 17:31Wait, a trap instruction? What does that actually
- 17:33do? The trap instruction forces the CPU to instantly
- 17:37switch from restricted user mode into kernel
- 17:40mode. Colonel Mode is where the core operating
- 17:42system operates with full, unrestricted privileges.
- 17:45Oh, I get it. It's literally like sliding a request
- 17:48under the thick bulletproof glass at a bank teller's
- 17:51window. The teller, the OS, takes your request,
- 17:55checks your ID badge against the rules, goes
- 17:57into the vault where you aren't allowed to go,
- 18:00gets your money, and slides it back out to you.
- 18:02Exactly. The program never gets to go into the
- 18:05vault itself. The OS switches to kernel mode,
- 18:08inspects the parameters of the request, checks
- 18:10the UID against that 9 -bit security code, and
- 18:14if everything is legal, it does the heavy lifting.
- 18:17Then it switches the CPU back to restricted user
- 18:19mode and returns control to the program. The
- 18:22bouncer is at the door of kernel mode, and the
- 18:24system call is the only way in. Which perfectly
- 18:27explains why there's a master key. The source
- 18:30text mentions a special user, the super user
- 18:32in Unix, or the administrator in Windows. That
- 18:36account has a UID that tells the bouncer to completely
- 18:38bypass all these protection rules. Right. The
- 18:41VIP pass. It's necessary for performing high
- 18:44-level system maintenance, but it also explains
- 18:46why it is so catastrophic if a hacker compromises
- 18:50an administrator account. They get full access
- 18:53to the vault. They absolutely do. And we should
- 18:55briefly mention how you, as a human user, actually
- 18:58interact with all these systems. While it's not
- 19:01technically part of the core OS kernel, the text
- 19:03highlights the shell, or the command interpreter.
- 19:07Ah, the classic blinking cursor on a black screen.
- 19:10Yeah, the shell is fundamentally just a user
- 19:12mode program. Its entire job is to read your
- 19:15terminal input. When you type a command and hit
- 19:17enter, the shell uses a system call to ask the
- 19:19OS to spawn a new child process to run whatever
- 19:22utility you asked for. It effortlessly handles
- 19:25all that background execution and input output
- 19:28redirection we talked about earlier. It is your
- 19:30direct human interface to the vast power of the
- 19:34operating system. So what does this all mean
- 19:36for you, the listener? We started by talking
- 19:39about the messy chaotic, completely unstructured
- 19:42electrical reality of the physical hardware inside
- 19:45your device. And what our source material so
- 19:48brilliantly illustrates is that the operating
- 19:50system is fundamentally a master of illusion.
- 19:53The ultimate illusionist. Yeah. It takes this
- 19:56chaotic tangle of raw silicon and electricity
- 19:59and through processes, virtual memory juggling,
- 20:03file abstractions, and tightly controlled system
- 20:05calls, it transforms that chaos into the highly
- 20:08structured, secure, and beautiful digital world
- 20:11that you interact with every single day. It really
- 20:14is a triumph of abstraction. If I can leave the
- 20:17listener with a final thought to ponder, building
- 20:19off the conclusion of our source material. The
- 20:21operating system's entire foundational purpose
- 20:24is to be an extended machine, to completely hide
- 20:27the ugly, complex, raw physical reality of the
- 20:30hardware behind these beautiful, clean, perfectly
- 20:33orchestrated software illusions. It makes you
- 20:36wonder how much of the digital infrastructure
- 20:38we rely on for our daily survival is just a carefully
- 20:42maintained mirage. And for some reason, all of
- 20:45those software abstractions were to suddenly
- 20:47peel away tomorrow. Would we even be able to
- 20:50comprehend the raw, physical reality of our own
- 20:52devices anymore? Man, that is a wild thought.
- 20:55If the illusion dropped, we'd just be staring
- 20:57at a piece of glass and metal, completely incapable
- 21:00of making it do a single thing. Just expensive
- 21:03paper weights. Exactly. Something to definitely
- 21:06think about the next time you seamlessly tap
- 21:08an icon and expect a file to just open. Thanks
- 21:11for taking this journey with us, and we'll catch
- 21:13you on the next Deep Dive.