👁 Preview — Study, Practice and Revise are open; mock tests and the rest of the syllabus unlock on subscription. Unlock all · ₹4,999
← Back to Computer Fundamentals
Study mode

Operating systems

Introduction to Operating Systems

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.

Definition and Functions of Operating 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:

  • Hardware Management: Controls and coordinates the use of hardware devices like the CPU, memory, disk drives, and input/output devices.
  • User Interface: Provides a way for users to interact with the computer, either through command lines or graphical interfaces.
  • Process Management: Manages running programs (processes), including their creation, execution, and termination.
  • Memory Management: Allocates memory to processes and manages the overall memory hierarchy.
  • File Management: Organizes files on storage devices and controls access to them.
  • Security and Access Control: Protects data and resources from unauthorized access.

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

Why is the OS Important?

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.

Types of Operating Systems

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).

Examples of Popular Operating Systems

  • Windows: Widely used desktop OS by Microsoft.
  • Linux: Open-source OS popular in servers and programming.
  • macOS: Apple's desktop OS for Mac computers.
  • Android: Mobile OS based on Linux for smartphones.
  • iOS: Apple's mobile OS for iPhones and iPads.

Process Management

A process is a program in execution. The OS manages multiple processes by controlling their states and scheduling their use of the CPU.

Process States

Every process goes through several states during its life cycle:

  • New: The process is being created.
  • Ready: The process is waiting to use the CPU.
  • Running: The process is currently using the CPU.
  • Waiting (Blocked): The process is waiting for some event (like input/output) to complete.
  • Terminated: The process has finished execution.
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)

Scheduling Algorithms

The OS uses scheduling algorithms to decide which process gets CPU time. Some common algorithms are:

  • First-Come, First-Served (FCFS): Processes are scheduled in the order they arrive.
  • Shortest Job First (SJF): Processes with the shortest burst time are scheduled first.
  • Round Robin (RR): Each process gets a fixed time slice (quantum) in a cyclic order.

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 and Multiprogramming

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 Management

Memory is where data and programs reside while the computer is running. The OS manages memory to ensure efficient use and protection.

Memory Hierarchy

Memory is organized in layers based on speed and size:

  • CPU Registers: Fastest and smallest memory inside the CPU.
  • Cache Memory: Small, fast memory close to CPU.
  • Main Memory (RAM): Larger but slower than cache; stores active programs.
  • Secondary Storage: Hard drives, SSDs; large but slow.
CPU Registers Cache Memory Main Memory (RAM) Secondary Storage

Virtual Memory

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.

Memory Allocation Techniques

Two common techniques for managing memory:

  • Paging: Divides memory into fixed-size blocks called pages. Logical memory addresses are mapped to physical memory.
  • Segmentation: Divides memory into variable-sized segments based on logical divisions like functions or data structures.

File Management

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.

File Systems

A file system defines how files are named, stored, and retrieved. Examples include NTFS (Windows), ext4 (Linux), and HFS+ (macOS).

Directory Structure

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]

File Operations

Common file operations managed by the OS include:

  • Create: Make a new file or directory.
  • Read: Access file contents.
  • Write: Modify or add data to a file.
  • Delete: Remove a file or directory.
  • Rename: Change the file or directory name.

User Interface and Shortcut Keys

The OS provides ways for users to interact with the computer:

Command Line Interface (CLI)

A text-based interface where users type commands to perform tasks. It is powerful for advanced users and scripting.

Graphical User Interface (GUI)

A visual interface with windows, icons, and menus that users interact with using a mouse or touch.

Common Shortcut Keys

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

Key Takeaways

  • Operating System manages hardware and software resources
  • Processes move through states: New, Ready, Running, Waiting, Terminated
  • Memory is managed using techniques like paging and virtual memory
  • Files are organized in hierarchical directories
  • Shortcut keys improve efficiency in OS environments
Key Takeaway:

Understanding OS fundamentals is crucial for computer knowledge and competitive exams.

Formula Bank

Average Waiting Time (AWT) in Scheduling
\[ \text{AWT} = \frac{\sum (\text{Waiting Time of all processes})}{\text{Number of processes}} \]
where: Waiting Time = Time a process waits in the ready queue before execution; Number of processes = total processes scheduled.
Example 1: Process State Transition Example Easy
A process is created and needs to read data from a disk before continuing execution. Describe the sequence of states the process goes through from creation to termination.

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

Example 2: Scheduling Algorithm Calculation (Round Robin) Medium
Four processes P1, P2, P3, and P4 arrive at time 0 with burst times 8, 4, 9, and 5 milliseconds respectively. Using Round Robin scheduling with a time quantum of 3 ms, calculate the average waiting time.

Step 1: List processes with burst times:

  • P1 = 8 ms
  • P2 = 4 ms
  • P3 = 9 ms
  • P4 = 5 ms

Step 2: Simulate Round Robin execution with quantum = 3 ms:

  • Time 0-3: P1 runs (remaining 5 ms)
  • Time 3-6: P2 runs (remaining 1 ms)
  • Time 6-9: P3 runs (remaining 6 ms)
  • Time 9-12: P4 runs (remaining 2 ms)
  • Time 12-15: P1 runs (remaining 2 ms)
  • Time 15-16: P2 runs (remaining 0 ms, finishes)
  • Time 16-19: P3 runs (remaining 3 ms)
  • Time 19-21: P4 runs (remaining 0 ms, finishes)
  • Time 21-23: P1 runs (remaining 0 ms, finishes)
  • Time 23-26: P3 runs (remaining 0 ms, finishes)

Step 3: Calculate completion times:

  • P1 completes at 23 ms
  • P2 completes at 16 ms
  • P3 completes at 26 ms
  • P4 completes at 21 ms

Step 4: Calculate waiting time = Completion time - Burst time - Arrival time (arrival = 0):

  • P1: 23 - 8 = 15 ms
  • P2: 16 - 4 = 12 ms
  • P3: 26 - 9 = 17 ms
  • P4: 21 - 5 = 16 ms

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.

Example 3: Memory Allocation Using Paging Medium
Given a page size of 1 KB, a logical address 2048, and the following page table mapping: page 0 -> frame 5, page 1 -> frame 3, page 2 -> frame 7. Find the physical address.

Step 1: Calculate page number and offset:

  • Page size = 1 KB = 1024 bytes
  • Logical address = 2048
  • Page number = \(\lfloor \frac{2048}{1024} \rfloor = 2\)
  • Offset = \(2048 \mod 1024 = 0\)

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.

Example 4: File Directory Structure Navigation Easy
Given a directory tree where the root has a folder "Documents" containing "Resume.docx" and "Notes.txt", and a folder "Pictures" containing "Vacation.jpg", explain how to access the file "Notes.txt".

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.

Example 5: Using Shortcut Keys for File Operations Easy
Demonstrate how to copy and paste a file named "Report.pdf" from one folder to another using shortcut keys in Windows.

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.

Tips & Tricks

Tip: Remember the process states using the mnemonic "N R R W T" (New, Ready, Running, Waiting, Terminated).

When to use: When recalling the lifecycle of a process during exams.

Tip: Use Round Robin scheduling for time-sharing systems to ensure fairness among processes.

When to use: When answering questions on scheduling algorithms.

Tip: Shortcut 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.

Tip: Visualize memory as layers from fastest (CPU registers) to slowest (secondary storage) to understand memory hierarchy.

When to use: When studying memory management concepts.

Tip: Use tables to compare OS types and scheduling algorithms for quick revision before exams.

When to use: For last-minute concept clarity.

Common Mistakes to Avoid

❌ Confusing process states, especially mixing 'waiting' with 'ready'.
✓ Remember 'waiting' means process is blocked waiting for I/O, 'ready' means waiting for CPU.
Why: Students often overlook the difference between waiting for CPU and waiting for I/O.
❌ Assuming all OS types are suitable for all tasks.
✓ Understand that real-time OS is for time-critical tasks, while batch OS is for bulk processing.
Why: Lack of clarity on OS application domains leads to this error.
❌ Incorrect calculation of average waiting time by not accounting for process arrival times.
✓ Include arrival times in scheduling calculations to get accurate waiting times.
Why: Students sometimes ignore arrival times, simplifying the problem incorrectly.
❌ Mixing physical and logical addresses in memory management questions.
✓ Logical addresses are generated by CPU; physical addresses are actual locations in memory after translation.
Why: Terminology confusion causes this mistake.
❌ Using shortcut keys from one OS environment in another without verification.
✓ Confirm shortcut keys for the specific OS (Windows, Linux, Mac) before use.
Why: Different OS have different shortcuts; assuming uniformity leads to errors.
✨ AI exam tools — try them free (included in every plan)
Tip: select any text above to Explain / Example / Simplify it.
Curated videos per subtopic
Top YouTube explainers, AI-ranked for your exam and language. Unlocks with subscription.
Unlock

Try Practice next.

Progress tracking is paywalled — subscribe to mark subtopics as understood and save your streak.

Go to practice →
Ask a doubt
Operating systems · 10 free messages
Ask me anything about this subtopic. You have 10 free messages this session — chat history isn't saved in preview.