Introduction to OS
What, Why, and How? The silent manager of your digital life.
What is an OS?
An Operating System (OS) is a piece of System Software that manages all the resources of a Computer System (both Hardware and Software).
It acts as an Interface between the User/Application and the Computer Hardware. Without it, talking to the CPU or RAM would be incredibly complex.
# Official Definition
"An interface is a shared boundary across which two or more separate components of a computer system exchange information. It abstracts the underlying implementation details, allowing users to interact with complex hardware through simple commands."
Think of it like a Restaurant Waiter 🍽️
You (the User) don't go into the kitchen (Hardware) to cook your own food. You just tell the Waiter (OS) what you want, and they handle the chaotic kitchen staff to get your meal ready.
User: Click "Save File"
OS (Interface): "Okay! driving the Hard Disk motor, finding empty sector 0x4F, writing binary data..."
Without OS: You would have to write code to spin the disk motor yourself! 😱
Operating System
Interface & Resource Allocator
Application Software
Designed for end-users to perform specific tasks.
System Software
Designed to run the computer hardware and application programs.
Why do we need it? (The No-OS Nightmare)
Imagine there is NO Operating System...
You open Instagram. Since there is no manager, Instagram has to write its own code to talk to the CPU and RAM. Greedy as it is, it decides it needs ALL the power to render reels smoothly.
"I can't start... Resources are locked!"
Problem 1: Resource Hacking
Without an OS, specific apps can "hack" or lock resources entirely for themselves. Instagram effectively owns your phone now.
Problem 2: No Multitasking
If you want to play BGMI while Instagram is open? Impossible. The hardware is already allocated.
Problem 3: Violation of DRY
Don't Repeat Yourself. Every single developer would have to write complex code just to manage RAM. Bundling this logic in every app makes them huge and buggy.
The Solution: OS as Allocator
We introduce the Operating System layer using the policy of Resource Allocation. The OS is the boss. Apps ask the OS for resources, and the OS decides how much to give.
Operating System (The Kernel)
"I will allocate resources fairly."
Functions of Operating System
The OS works as a Government for the computer, managing all major departments.
Process Management
Creating, scheduling, and terminating processes (programs in execution). Decides who gets the CPU.
Memory Management
Tracks which bytes of RAM are used by which app. Handles allocation and de-allocation.
Device Management
Manages device drivers (Keyboard, Mouse, Printer). Handles inputs and outputs efficiently.
File Management
Organizes data into files and directories. Handles creation, deletion, and access permissions.
Security
Prevents unauthorized access (Password protection). Protects OS memory from malicious apps.
Command Interpreter
Interprets user commands (CLI/GUI) and translates them into system calls.
Goals of Operating System
We never want the CPU to be idle.
→ OS Switch to P2
"Don't let the brain sleep!"
Every process must get a chance to execute.
while(True)... P2 waits forever?
NO! OS force switches.
Important jobs (like Antivirus or System tasks) run first.
Antivirus (High) comes
→ OS runs AVL first.
Types of Operating Systems
Single Process OS Oldest
- Only ONE process executes at a time.
- Violates all goals (CPU Idle during I/O, Starvation possible).
- Example: MS-DOS.
Batch Processing OS
Jobs with similar requirements are grouped into "Batches" and executed one by one. (Like washing all white clothes together, then colored ones).
Multi-Programming OS Efficient
Maximizes CPU utilization using Context Switching.
while(true) loop and never waits for I/O, it will keep the CPU forever. Process B starves.Multi-Tasking (Time Sharing) OS
Logical extension of Multi-programming. Solves starvation using Time Quantum (Round Robin).
Each process gets the CPU for a fixed time (e.g., 2 nanoseconds). Even if P1 has an infinite loop, it is forced out after 2ns so P2 can run.
RTOS (Real Time OS)
Strict time deadlines. Data must be processed within a fixed time limit.
Missing deadline = Failure.
Airbags, ParachutesMissing deadline = Lag.
Video StreamingDistributed OS
Multiple independent computers appear as a single system. Loosely connected.
Example: LOCUS, Cloud Computing clusters.