What is an Operating System?
Let's start with the simplest question: what actually is an operating system? At its core, an operating system (OS) is a piece of software that manages your computer's hardware and software resources. It's the middleman between you and the raw machinery inside your device.
Think of it like a restaurant manager. The customers (you) don't talk directly to the chefs (CPU), the waiters (I/O devices), or the inventory room (memory and storage). Instead, the manager coordinates everything โ taking your order, making sure the kitchen gets it, ensuring ingredients are available, and bringing the food back to you. Without the manager, it would be chaos.
The operating system does the same thing. When you click "Save" in a document, you don't need to know which part of the hard drive to write to, how to format the data, or how to physically move the disk head. The OS handles all of that invisibly.
What Does an OS Actually Do?
The operating system has five primary jobs:
- Process Management โ Creating, scheduling, and terminating processes. When you open five browser tabs, the OS decides how to share the CPU between them.
- Memory Management โ Tracking which parts of RAM are in use and by whom. When a program closes, the OS reclaims that memory for something else.
- File System Management โ Organizing data on storage devices. Creating folders, reading files, and keeping track of where everything is stored.
- I/O Management โ Communicating with hardware devices. Keyboard input, screen output, network data โ the OS orchestrates it all.
- Security & Access Control โ Making sure only authorized users and programs can access sensitive resources.
Every single thing you do on a computer โ from typing a letter to streaming a movie to sending an email โ involves the operating system coordinating these five functions behind the scenes.
System Calls: How Programs Talk to the OS
Programs don't directly access hardware. That would be dangerous โ imagine every app being able to read your entire hard drive or control your screen without permission. Instead, programs ask the OS to do things on their behalf through something called system calls.
A system call is like going through an official channel. When a program needs to read a file, it doesn't reach into the disk itself. It makes a system call: "Hey OS, please read this file for me." The OS checks if the program has permission, performs the operation, and returns the result.
This is a fundamental concept. The OS acts as a gatekeeper, ensuring that programs play nice with each other and don't break anything.
Kernel vs. User Mode
To enforce this gatekeeping, the OS operates in two distinct modes:
- Kernel Mode โ The OS's privileged mode. In this mode, the code has unrestricted access to all hardware and memory. This is where the OS itself runs.
- User Mode โ The restricted mode where applications run. Programs in user mode can't directly access hardware or critical memory. They must ask the OS for help through system calls.
Think of it like a building with restricted floors. You (the user) can walk around the lobby and offices (user mode), but to access the server room or electrical panel (kernel mode), you need to go through security and get authorization.
When a program makes a system call, the CPU switches from user mode to kernel mode, the OS performs the operation, and then switches back. This transition is fast but essential โ it's the boundary that keeps your system stable and secure.