Imagine you want to watch a movie on your smartphone or use a word processor on your laptop. How does your device know how to play the video or save your document? The answer lies in a special software called the Operating System (OS). An OS is the essential software that manages all the hardware and software on a computer, making it possible for you to interact with the machine easily and efficiently.
At its core, the Operating System acts as a bridge between the physical parts of a computer (called hardware) and the programs you run (called software). Without an OS, you would have to control hardware directly, which is complex and impractical.
In this chapter, we will explore what an Operating System is, how it works, and why it is vital for every computer system.
An Operating System is a system software that manages computer hardware and software resources and provides common services for computer programs. It is the first program loaded when a computer starts and remains active while the computer is on.
The main functions of an OS include:
Think of the OS as the manager of a busy office. It assigns tasks to employees (hardware), schedules meetings (processes), keeps track of documents (files), and ensures everything runs smoothly.
graph TD User[User Commands/Applications] OS[Operating System] Hardware[Hardware Components] User -->|Requests| OS OS -->|Controls| Hardware Hardware -->|Status/Feedback| OS OS -->|Responses| User
Without an OS, every program would need to include code to manage hardware, which would be inefficient and error-prone. The OS provides a consistent environment for software, making programming easier and computers more user-friendly.
Operating Systems come in different types, each designed for specific purposes. Understanding these types helps you know which OS suits which task.
| Type of OS | Key Features | Typical Use Cases |
|---|---|---|
| Batch OS | Processes batches of jobs without user interaction; jobs are queued and executed sequentially. | Early mainframe computers, bulk data processing. |
| Time-Sharing OS | Allows multiple users to share system resources simultaneously by rapidly switching between tasks. | Multi-user systems, university servers. |
| Distributed OS | Manages a group of independent computers and makes them appear as a single system. | Cloud computing, networked systems. |
| Real-Time OS | Processes data and events within strict time constraints. | Embedded systems, medical devices, industrial robots. |
| Mobile OS | Optimized for mobile devices with touch interfaces and wireless connectivity. | Smartphones, tablets (e.g., Android, iOS). |
A process is a program in execution. The OS manages multiple processes by controlling their states and scheduling their use of the CPU.
Every process goes through several states during its life cycle:
stateDiagram-v2 [*] --> New New --> Ready Ready --> Running Running --> Waiting Waiting --> Ready Running --> Terminated
Mnemonic to remember states: N R R W T (New, Ready, Running, Waiting, Terminated)
The OS uses scheduling algorithms to decide which process gets CPU time. Some common algorithms are:
For example, in a time-sharing system like your computer, Round Robin ensures fairness by giving each program a small time to run before switching to the next.
Multitasking allows multiple processes to run seemingly at the same time by rapidly switching the CPU among them.
Multiprogramming keeps several programs in memory simultaneously to maximize CPU usage.
Memory is where data and programs reside while the computer is running. The OS manages memory to ensure efficient use and protection.
Memory is organized in layers based on speed and size:
Sometimes, the RAM is not enough to hold all running programs. The OS uses virtual memory to extend RAM by temporarily transferring data to disk storage. This allows larger programs to run but may slow down performance.
Two common techniques for managing memory:
Files are how data is stored permanently on storage devices. The OS organizes files and directories to help users and programs find and manage data easily.
A file system defines how files are named, stored, and retrieved. Examples include NTFS (Windows), ext4 (Linux), and HFS+ (macOS).
Files are organized in directories (folders), which can contain other directories, forming a hierarchical tree structure.
graph TD Root[Root Directory] Root --> Dir1[Documents] Root --> Dir2[Pictures] Dir1 --> File1[Resume.docx] Dir1 --> File2[Notes.txt] Dir2 --> File3[Vacation.jpg]
Common file operations managed by the OS include:
The OS provides ways for users to interact with the computer:
A text-based interface where users type commands to perform tasks. It is powerful for advanced users and scripting.
A visual interface with windows, icons, and menus that users interact with using a mouse or touch.
Using shortcut keys speeds up tasks. Here are some frequently used shortcuts in Windows and Linux GUIs:
| Action | Windows/Linux Shortcut |
|---|---|
| Copy | Ctrl + C |
| Paste | Ctrl + V |
| Cut | Ctrl + X |
| Undo | Ctrl + Z |
| Save | Ctrl + S |
| Select All | Ctrl + A |
Step 1: The process starts in the New state when it is created.
Step 2: It moves to the Ready state, waiting for the CPU.
Step 3: When scheduled, it enters the Running state.
Step 4: The process requests disk input, so it moves to the Waiting state until the I/O completes.
Step 5: After I/O completion, it returns to the Ready state.
Step 6: Once again scheduled, it runs (Running state) until it finishes.
Step 7: Finally, it moves to the Terminated state.
Answer: New -> Ready -> Running -> Waiting -> Ready -> Running -> Terminated
Step 1: List processes with burst times:
Step 2: Simulate Round Robin execution with quantum = 3 ms:
Step 3: Calculate completion times:
Step 4: Calculate waiting time = Completion time - Burst time - Arrival time (arrival = 0):
Step 5: Calculate average waiting time:
\[ \text{AWT} = \frac{15 + 12 + 17 + 16}{4} = \frac{60}{4} = 15 \text{ ms} \]
Answer: Average waiting time is 15 milliseconds.
Step 1: Calculate page number and offset:
Step 2: Find frame number for page 2 from the page table: frame 7.
Step 3: Calculate physical address:
\[ \text{Physical Address} = (\text{Frame Number} \times \text{Page Size}) + \text{Offset} = (7 \times 1024) + 0 = 7168 \]
Answer: The physical address is 7168.
Step 1: Start at the root directory.
Step 2: Navigate to the "Documents" folder.
Step 3: Inside "Documents", locate the file "Notes.txt".
Answer: The path to the file is /Documents/Notes.txt.
Step 1: Select the file "Report.pdf" by clicking on it.
Step 2: Press Ctrl + C to copy the file.
Step 3: Navigate to the destination folder.
Step 4: Press Ctrl + V to paste the file.
Answer: The file "Report.pdf" is copied to the new folder using the shortcuts Ctrl + C and Ctrl + V.
When to use: When recalling the lifecycle of a process during exams.
When to use: When answering questions on scheduling algorithms.
Ctrl + C to copy and Ctrl + V to paste files quickly in Windows and Linux GUIs. When to use: During practical file management tasks or related questions.
When to use: When studying memory management concepts.
When to use: For last-minute concept clarity.
Progress tracking is paywalled — subscribe to mark subtopics as understood and save your streak.
Go to practice →