Key Components of Operating Systems
Key Components of Operating Systems
Contents
🧠 Operating System Components..................................9
1 Process Management..............................................9
💡 Definition:...........................................................9
⚙️Functions:...........................................................9
🧩 Example:..............................................................9
🧠 Why It’s Important:.............................................9
2 Main Memory Management...................................9
💡 Definition:...........................................................9
⚙️Functions:...........................................................9
🧩 Example:..............................................................9
🧠 Why It’s Important:.............................................9
3 Secondary Storage Management..........................10
💡 Definition:.........................................................10
⚙️Functions:.........................................................10
🧩 Example:............................................................10
🧠 Why It’s Important:...........................................10
4 I/O System Management......................................10
💡 Definition:.........................................................10
⚙️Functions:.........................................................10
🧩 Example:............................................................10
🧠 Why It’s Important:...........................................10
5 Protection System.................................................11
💡 Definition:.........................................................11
⚙️Functions:.........................................................11
🧩 Example:............................................................11
🧠 Why It’s Important:...........................................11
6 Networking...........................................................11
💡 Definition:.........................................................11
⚙️Functions:.........................................................11
🧩 Example:............................................................11
🧠 Why It’s Important:...........................................11
7 Command Line Interpreter (CLI)...........................12
P a g e 1 | 60
Operating system Final NOTES by anees ahmad
💡 Definition:.........................................................12
⚙️Functions:.........................................................12
🧩 Example:............................................................12
🧠 Why It’s Important:...........................................12
🧾 Summary Table: OS Components..............................12
🧠 Operating System Services........................................12
1 Program Execution................................................13
💡 Definition:.........................................................13
⚙️How It Works:..................................................13
🧩 Example:............................................................13
🧠 Why It’s Important:...........................................13
🧩 Analogy:.............................................................13
2 I/O Operations.......................................................13
💡 Definition:.........................................................13
⚙️How It Works:..................................................13
🧩 Example:............................................................13
🧠 Why It’s Important:...........................................13
🧩 Analogy:.............................................................14
3 File System Manipulation.....................................14
💡 Definition:.........................................................14
⚙️How It Works:..................................................14
🧩 Example:............................................................14
🧠 Why It’s Important:...........................................14
🧩 Analogy:.............................................................14
4 Communication Services.......................................14
💡 Definition:.........................................................14
⚙️How It Works:..................................................14
🧩 Example:............................................................14
🧠 Why It’s Important:...........................................14
🧩 Analogy:.............................................................15
5 Error Detection......................................................15
💡 Definition:.........................................................15
⚙️How It Works:..................................................15
P a g e 2 | 60
Operating system Final NOTES by anees ahmad
🧩 Example:............................................................15
🧠 Why It’s Important:...........................................15
🧩 Analogy:.............................................................15
6 Resource Management.........................................15
💡 Definition:.........................................................15
⚙️How It Works:..................................................15
🧩 Example:............................................................15
🧠 Why It’s Important:...........................................15
🧩 Analogy:.............................................................16
7 Accounting.............................................................16
💡 Definition:.........................................................16
⚙️How It Works:..................................................16
🧩 Example:............................................................16
🧠 Why It’s Important:...........................................16
🧩 Analogy:.............................................................16
8 Protection..............................................................16
💡 Definition:.........................................................16
⚙️How It Works:..................................................16
🧩 Example:............................................................16
🧠 Why It’s Important:...........................................16
🧩 Analogy:.............................................................17
🧾 Summary Table: OS Services.....................................17
🧠 Operating System Kernel & System Calls..................17
1 What is the OS Kernel?..........................................17
💡 Definition:.........................................................17
⚙️Functions of the Kernel:...................................17
🧩 Example:............................................................18
🧩 2 What Are System Calls?......................................18
💡 Definition:.........................................................18
⚙️How It Works:..................................................18
🧩 Example:............................................................18
🧠 Why System Calls Are Important:......................18
🧩 3 Types of System Calls.........................................18
P a g e 3 | 60
Operating system Final NOTES by anees ahmad
1. Process Control System Calls............................18
💡 Definition:.........................................................18
⚙️Common Process Control Calls:.......................18
🧩 Example:............................................................19
🧩 Analogy:.............................................................19
2. File Management System Calls.........................19
💡 Definition:.........................................................19
⚙️Common File Management Calls:....................19
🧩 Example:............................................................19
🧩 Analogy:.............................................................19
3. Device Management System Calls....................19
💡 Definition:.........................................................19
⚙️Common Device Management Calls:...............19
🧩 Example:............................................................19
🧩 Analogy:.............................................................19
4. Information Maintenance System Calls............20
💡 Definition:.........................................................20
⚙️Common Information Maintenance Calls:.......20
🧩 Example:............................................................20
🧩 Analogy:.............................................................20
5. Communication System Calls............................20
💡 Definition:.........................................................20
⚙️Common Communication Calls:.......................20
🧩 Example:............................................................20
🧩 Analogy:.............................................................20
🧾 Summary Table: System Calls....................................20
🧠 System Call Execution & OS Structures.....................21
1 System Call Execution............................................21
💡 What is System Call Execution?.........................21
⚙️Steps of System Call Execution:........................21
🧩 Example:............................................................21
🧠 Why System Call Execution Is Important:..........21
🧩 Analogy:.............................................................22
P a g e 4 | 60
Operating system Final NOTES by anees ahmad
2 Semantics of System Call Execution......................22
💡 What is Semantics of System Call Execution?. . .22
⚙️Key Points of Semantics:..................................22
🧩 Example:............................................................22
🧠 Why Semantics Matter:.....................................22
🧩 Analogy:.............................................................22
3 OS Structures.........................................................22
💡 Key OS Structures:.............................................22
1️ Simple Structure (Monolithic Kernel)................23
💡 Definition:.........................................................23
⚙️Characteristics:.................................................23
🧩 Example:............................................................23
🧠 Why It’s Important:...........................................23
2️ Layered Approach.............................................23
💡 Definition:.........................................................23
⚙️Characteristics:.................................................23
🧩 Example:............................................................23
🧠 Why It’s Important:...........................................23
3️ Microkernel.......................................................23
💡 Definition:.........................................................23
⚙️Characteristics:.................................................24
🧩 Example:............................................................24
🧠 Why It’s Important:...........................................24
4️ Virtual Machines (VMs).....................................24
💡 Definition:.........................................................24
⚙️Characteristics:.................................................24
🧩 Example:............................................................24
🧠 Why It’s Important:...........................................24
🧾 Summary Table: OS Structures..................................24
Components of Operating System................................25
1. Introduction..........................................................25
2. Major Components of Operating System.............25
1. Kernel...............................................................25
2. Process Management.......................................25
P a g e 5 | 60
Operating system Final NOTES by anees ahmad
3. Memory Management......................................26
4. File Management..............................................26
5. Device Management.........................................26
6. User Interface (UI)............................................26
3. Diagram: Components of Operating System........27
4. Quick Summary Table...........................................27
System Design and Implementation (Operating System)27
Basic Idea (In Very Simple Words)............................27
Main Parts of System Design & Implementation......27
1. User......................................................................27
Definition..............................................................27
Simple Explanation...............................................28
Example................................................................28
2. System Administrator (Admin).............................28
Definition..............................................................28
Simple Explanation...............................................28
Example................................................................28
3. Mechanism...........................................................28
Definition..............................................................28
Simple Explanation...............................................28
Examples..............................................................28
4. Policy....................................................................29
Definition..............................................................29
Simple Explanation...............................................29
Examples..............................................................29
🔥 Mechanism vs Policy.............................................29
Best Analogy.........................................................29
5. Language (Implementation Language).................29
Definition..............................................................29
Simple Explanation...............................................29
Common Languages Used....................................29
How All These Fit Together (Big Picture)..................29
One-Line Summary...................................................30
Mnemonic to Remember Everything Easily 🧠..........30
P a g e 6 | 60
Operating system Final NOTES by anees ahmad
“U-S-M-P-L” → Use Smart Machines Properly Lovingly 😄 30
UNIX and Linux – Detailed Overview & Key Differences30
1. What is UNIX?.......................................................30
Definition..............................................................30
Simple Explanation...............................................30
Key Features of UNIX............................................30
Examples of UNIX Systems...................................30
2. What is Linux?......................................................30
Definition..............................................................30
Simple Explanation...............................................30
Key Features of Linux............................................30
Examples of Linux Distributions (Distros).............30
3. Relationship Between UNIX and Linux..................31
Very Important Concept.......................................31
Analogy.................................................................31
4. Key Differences Between UNIX and Linux (⭐ Most Important Part ⭐)31
Comparison Table (Write This in Exam 💯)............31
5. Architecture Similarity (UNIX & Linux)..................31
Explanation...........................................................31
6. Why Linux Became More Popular Than UNIX?.....31
Reasons (Bullet Points for Exams)........................31
7. Security Comparison.............................................32
8. Mnemonic to Remember Differences 🧠...............32
“UNIX is COSTLY & CLOSED, Linux is FREE & FLEXIBLE” 32
9. One-Line Summary...............................................32
Browsing Directory Structure of UNIX..........................32
1. What is UNIX Directory Structure?.......................32
Definition (Exam-ready)........................................32
Simple Explanation...............................................32
Analogy.................................................................32
2. Root Directory ( / )................................................32
Very Important Point............................................32
3. Important Directories in UNIX (Must Remember) 32
/bin (Binary)..........................................................32
P a g e 7 | 60
Operating system Final NOTES by anees ahmad
/sbin (System Binary)............................................33
/etc (Editable Text Configuration)........................33
/home...................................................................33
/root.....................................................................33
/usr (User System Resources)...............................33
/var (Variable files)...............................................34
/tmp (Temporary files).........................................34
/dev (Devices).......................................................34
/lib (Libraries).......................................................34
/proc (Process information)..................................34
4. Diagram of UNIX Directory Structure...................34
5. Commands Used to Browse Directory Structure. .35
1. pwd (Print Working Directory)..........................35
2. ls (List)...............................................................35
3. cd (Change Directory).......................................35
4. tree...................................................................35
5. find...................................................................35
6. du (Disk Usage).................................................35
7. stat....................................................................35
6. Important Comparison (Exam Alert 🚨).................36
/bin vs /sbin..........................................................36
7. Mnemonic to Remember Directories 🧠................36
“Be Safe Every Home User Visits The Dark Library Properly” 36
8. One-Line Exam Summary......................................36
PROCESS (IN DETAIL)....................................................36
1️What is a Process?..................................................36
✅ Definition...........................................................36
🔹 Simple Explanation............................................36
🔹 Program vs Process (Must-know comparison). .36
🔹 What Does a Process Contain? (VERY IMPORTANT) 37
🔹 Real-Life Analogy...............................................37
2️ CPU-Bound and I/O-Bound Processes...................37
🔹 CPU Burst & I/O Burst (KEY IDEA)..........................37
2️ A. CPU-Bound Process (IN DETAIL)........................37
P a g e 8 | 60
Operating system Final NOTES by anees ahmad
✅ Definition...........................................................37
🔹 Characteristics...................................................37
🔹 Examples...........................................................37
🔹 Analogy.............................................................37
🧠 Mnemonic.........................................................37
2️ B. I/O-Bound Process (IN DETAIL)..........................38
✅ Definition...........................................................38
🔹 Characteristics...................................................38
🔹 Examples...........................................................38
🔹 Analogy.............................................................38
🧠 Mnemonic.........................................................38
🔥 CPU-Bound vs I/O-Bound (EXAM TABLE)..............38
3️ Mechanism of Process Execution (VERY IMPORTANT) 38
🔹 Step-by-Step Mechanism of Process Execution....38
🟢 Step 1: Program Submission..............................38
🟢 Step 2: Process Creation....................................38
🟢 Step 3: Process Enters Ready State....................38
🟢 Step 4: CPU Allocation (Dispatch)......................39
🟢 Step 5: Execution Cycle......................................39
🟢 Step 6: Context Switching..................................39
🟢 Step 7: Process Termination..............................39
🔹 Process Execution Flow.........................................39
4 Why This Mechanism Is Important?.....................39
🧠 MASTER MNEMONICS (REVISION GOLD)..............39
🔹 Process Definition.............................................39
🔹 CPU vs I/O.........................................................39
✨ FINAL 2-LINE SUMMARY.......................................39
PROCESS STATES & PROCESS CONTROL BLOCK (PCB). .39
PROCESS STATES (IN DETAIL)....................................39
1️ Why Do We Need Process States?........................39
3️ Explanation of Each Process State (DETAILED)......40
🟢 1. NEW STATE....................................................40
🔹 Meaning............................................................40
🧠 Example.............................................................40
P a g e 9 | 60
Operating system Final NOTES by anees ahmad
📝 Exam Point........................................................40
🟡 2. READY STATE.....................................................40
🔹 Meaning............................................................40
🧠 Example.............................................................40
📝 Exam Point........................................................40
🔴 3. RUNNING STATE................................................40
🔹 Meaning............................................................40
🧠 Example.............................................................40
📝 Exam Point........................................................41
🔵 4. WAITING (BLOCKED) STATE...............................41
🔹 Meaning............................................................41
🧠 Example.............................................................41
📝 Exam Point........................................................41
⚫ 5. TERMINATED STATE.........................................41
🔹 Meaning............................................................41
🧠 Example.............................................................41
📝 Exam Point........................................................41
4️ Process State Transitions (VERY IMPORTANT)......41
5️ Process State Diagram (DESCRIBE IN EXAM).........41
🧠 Mnemonic for Process States................................41
PROCESS CONTROL BLOCK (PCB)..................................42
What is Process Control Block (PCB)?.......................42
✅ Definition...........................................................42
7 Why PCB is Needed?.............................................42
8 Information Stored in PCB (IN DETAIL).................42
🔹 1. Process Identification....................................42
🔹 2. Process State.................................................42
🔹 3. CPU Context Information..............................42
🔹 4. Scheduling Information.................................42
🔹 5. Memory Management Information..............42
🔹 6. I/O Status Information...................................42
🧠 PCB Content Mnemonic........................................42
9 PCB MECHANISM & COMPLETE WORKING (STEP-BY-STEP) 43
🔹 Step 1: Process Creation........................................43
P a g e 10 | 60
Operating system Final NOTES by anees ahmad
🔹 Step 2: Process Execution......................................43
🔹 Step 3: Context Switch Occurs..............................43
🔹 Step 4: Saving Process State..................................43
🔹 Step 5: Loading Next Process................................43
🔹 Step 6: Process Termination..................................43
🔁 PCB LIFE CYCLE......................................................43
🔥 Key Exam Difference: PCB vs Program..................43
🔚 FINAL SUMMARY...................................................43
PROCESS SCHEDULING QUEUES (IN DETAIL)................44
1 What is a Process Scheduling Queue?...................44
✅ Definition...........................................................44
🔹 Simple Explanation............................................44
2 Why Are Scheduling Queues Needed?.................44
3 Types of Process Scheduling Queues.....................44
4 JOB QUEUE (IN DETAIL).............................................44
✅ Definition...........................................................44
🔹 Key Characteristics............................................44
🔹 What Happens Here?........................................44
🔹 Analogy.............................................................45
5 READY QUEUE (IN DETAIL)....................................45
✅ Definition...........................................................45
🔹 Key Characteristics............................................45
🔹 What Happens Here?........................................45
🔹 Analogy.............................................................45
6 DEVICE QUEUE (IN DETAIL)....................................45
✅ Definition...........................................................45
🔹 Key Characteristics............................................45
🔹 Examples...........................................................45
🔹 Analogy.............................................................45
7 PROCESS MIGRATION BETWEEN QUEUES (VERY IMPORTANT) 46
🔄 Step-by-Step Process Migration............................46
🟢 Step 1: Job Submission......................................46
🟢 Step 2: Admission to Memory...........................46
🟢 Step 3: CPU Allocation.......................................46
P a g e 11 | 60
Operating system Final NOTES by anees ahmad
🟢 Step 4: I/O Request............................................46
🟢 Step 5: I/O Completion......................................46
🟢 Step 6: Process Termination..............................46
8 COMPLETE MECHANISM (HOW OS USES QUEUES)46
🔹 Mechanism of Process Scheduling Queues.......46
9 COMMON EXAM COMPARISON (VERY USEFUL)....47
1 MNEMONICS FOR QUICK REVISION 🧠...................47
🔹 Queues..............................................................47
🔹 Migration...........................................................47
🔚 FINAL SUMMARY..................................................47
SCHEDULING (IN OPERATING SYSTEM)........................47
1️ What is Scheduling?..............................................47
✅ Definition...........................................................47
🔹 Simple Explanation............................................47
🔹 Real-Life Analogy...............................................47
2️ Why Scheduling is Needed?..................................47
3️ Types of Scheduling (VERY IMPORTANT)..............48
4 LONG-TERM SCHEDULING (JOB SCHEDULER)...........48
✅ Definition...........................................................48
🔹 What It Controls................................................48
🔹 How It Works.....................................................48
🔹 Frequency..........................................................48
🔹 Example.............................................................48
🧠 Analogy..............................................................48
📌 Exam Tip............................................................48
5 SHORT-TERM SCHEDULING (CPU SCHEDULER)..........48
✅ Definition...........................................................49
🔹 What It Controls................................................49
🔹 How It Works.....................................................49
🔹 Frequency..........................................................49
🔹 Example.............................................................49
🧠 Analogy..............................................................49
📌 Exam Tip............................................................49
6 MEDIUM-TERM SCHEDULING (SWAPPER)................49
P a g e 12 | 60
Operating system Final NOTES by anees ahmad
✅ Definition...........................................................49
🔹 Key Concept: Swapping.....................................49
🔹 What It Controls................................................49
🔹 How It Works.....................................................49
🔹 Frequency..........................................................49
🧠 Analogy..............................................................50
📌 Exam Tip............................................................50
7 COMPARISON TABLE.................................................50
8 HOW ALL SCHEDULERS WORK TOGETHER (BIG PICTURE) 50
🧠 MASTER MNEMONIC (REVISION GOLD)................50
🔚 FINAL SUMMARY...................................................50
CONTEXT SWITCHING (OPERATING SYSTEMS).............50
1️ Definition..............................................................50
2️ Simple Explanation................................................51
🔹 Analogy.............................................................51
3 What Exactly Is Saved During Context Switch?......51
4 When Does Context Switching Occur?..................51
5 Step-by-Step Mechanism of Context Switching....51
🔹 Exam Diagram...................................................51
6 Why Context Switching Is Important.....................51
7 Disadvantages / Cost.............................................52
8 Analogy to Remember for Exam............................52
9 Mnemonic (For Quick Revision).............................52
🔚 Final Summary.......................................................52
FORK() IN OPERATING SYSTEMS...................................52
1 Definition...............................................................52
2 Key Points About Fork...........................................52
3 How Fork Works (Mechanism)..............................52
4 Example in C (Unix/Linux)......................................52
🔹 Explanation........................................................53
5 Important Notes About Fork.................................53
🔹 Copy-On-Write Optimization.............................53
6 Analogy (For Easy Memory)...................................53
7 Exam Tip................................................................53
P a g e 13 | 60
Operating system Final NOTES by anees ahmad
🔚 Final Summary......................................................53
THREADS IN OPERATING SYSTEMS...............................53
1 Definition...............................................................53
2 Key Points About Threads......................................54
🔹 Analogy (Easy to Remember)............................54
3 Advantages of Threads..........................................54
4 Types of Threads...................................................54
🔹 1. User-Level Threads (ULT)...............................54
🔹 2. Kernel-Level Threads (KLT)............................54
🔹 3. Hybrid Threading...........................................54
5 Thread Components (IN DETAIL)...........................54
6 Thread States.........................................................54
7 Thread vs Process (Exam Table)............................55
8 Thread Mechanism / Execution.............................55
🔹 Step 1: Thread Creation.....................................55
🔹 Step 2: Thread Scheduling.................................55
🔹 Step 3: Thread Execution...................................55
🔹 Step 4: Termination...........................................55
9 Real-Life Example..................................................55
🔟 Mnemonics for Quick Revision..............................55
🔚 Final Summary.......................................................55
🧠 Operating System
Components
An Operating System (OS) is made up of several
important components that manage different
hardware and software resources in the system.
The OS’s primary role is to ensure the efficient
operation of the computer system and provide an
interface for users to interact with the machine.
1 Process Management
💡 Definition:
P a g e 14 | 60
Operating system Final NOTES by anees ahmad
Process Management is the function of the OS ⚙️Functions:
responsible for managing processes in the system. A
process is simply a program in execution. Memory allocation: Decides which
processes will be loaded into which areas of
⚙️Functions: memory.
Memory deallocation: Frees memory once
Creation and termination of processes: processes are done executing.
The OS manages when and how processes Memory protection: Prevents one process
are started and stopped. from interfering with the memory space of
Process scheduling: It decides the order in another.
which processes will run (CPU scheduling). Virtual memory: Allows programs to use
Process synchronization: Ensures that more memory than physically available by
processes coordinate their actions without swapping data between RAM and disk.
interfering with each other.
Inter-process communication (IPC):
Allows processes to share data and
synchronize actions. 🧩 Example:
💡 Definition:
2 Main Memory Management
Secondary storage refers to non-volatile memory
💡 Definition: like hard drives, SSDs, and external storage
devices. The OS is responsible for managing this
Main memory management involves managing permanent storage.
RAM (Random Access Memory), where programs
and data are stored temporarily during execution.
P a g e 15 | 60
Operating system Final NOTES by anees ahmad
⚙️Functions: Buffering: The OS stores data temporarily
in memory buffers before sending it to an
File system management: The OS manages I/O device or from an I/O device.
the organization and storage of files on Spooling: It queues I/O tasks to be executed
secondary storage. later, which prevents a device from being
Disk scheduling: Controls the order in overloaded.
which disk requests are processed.
Data retrieval: Ensures fast and efficient
reading and writing of data from storage
devices. 🧩 Example:
Backup and recovery: Provides
mechanisms to recover data in case of When you print a document, the OS manages how
failure. the document is sent from memory to the printer
(I/O device). If the printer is busy, the OS can queue
the print job using spooling.
🧩 Example:
When you save a document, it is stored on the hard 🧠 Why It’s Important:
drive or SSD. The OS organizes the file and ensures
it is written to the correct location on the disk. Prevents device conflicts by managing
access to hardware.
Improves data transfer efficiency between
the CPU and external devices.
🧠 Why It’s Important: Buffers data to prevent I/O bottlenecks.
P a g e 18 | 60
Operating system Final NOTES by anees ahmad
Multitasking: The OS needs to manage and 🧠 Why It’s Important:
execute multiple programs concurrently.
Ensures fair allocation of CPU time to Efficiency: Ensures that I/O devices are
different processes. utilized properly without affecting the
system’s performance.
Concurrency: Allows multiple I/O
operations to occur simultaneously with
🧩 Analogy: CPU work.
P a g e 19 | 60
Operating system Final NOTES by anees ahmad
When you save a file in a word processor, the OS In a chat application, the OS handles
writes the data to the disk, organizing it in a file communication between the sender and receiver,
directory structure (folders, files). ensuring that messages are delivered properly.
🧩 Analogy:
🧩 Analogy:
Think of a librarian organizing books in a library.
The OS is the librarian who places each book in its Think of two people talking. The OS is like a
designated shelf and makes sure only authorized translator or interpreter who ensures both people
people can borrow the books. understand each other, even if they speak different
languages.
4 Communication Services
5 Error Detection
💡 Definition:
💡 Definition:
Communication services enable processes to
communicate with each other, either within the The OS monitors the system for errors and
same system (inter-process communication, IPC) provides mechanisms to handle them. Errors can be
or across systems (network communication). hardware-related (e.g., memory errors) or software-
related (e.g., invalid instructions).
⚙️How It Works:
⚙️How It Works:
1. Message Passing: Processes exchange data
using messages. 1. The OS continuously checks for faulty
2. Shared Memory: Multiple processes can hardware (e.g., disk failures, memory
access the same area of memory to issues).
communicate. 2. If a process encounters an illegal
3. The OS manages communication buffers instruction or invalid memory access, the
and synchronization between processes. OS detects it and can terminate or handle
the error.
🧩 Example: 3. Error logs may be maintained for
debugging purposes.
🧩 Example:
P a g e 20 | 60
Operating system Final NOTES by anees ahmad
If a program tries to access memory it doesn’t own
(segmentation fault), the OS detects the error and
terminates the program to prevent crashes. 🧠 Why It’s Important:
7 Accounting
P a g e 21 | 60
Operating system Final NOTES by anees ahmad
🧠 Why It’s Important: Prevents malicious attacks and data
breaches.
Helps with resource allocation and billing Ensures privacy and confidentiality.
(especially in cloud computing or shared Keeps the system secure and prevents
systems). unauthorized actions.
Allows performance monitoring and
optimization.
🧩 Analogy:
P a g e 23 | 60
Operating system Final NOTES by anees ahmad
Abstraction: They provide a high-level When you run a program, the OS uses system calls
abstraction, so user programs don’t need to like fork() to create a new process and exec() to
interact directly with hardware. execute it. If the program finishes, the OS uses
Security: They control how processes exit() to clean up the process.
access resources, preventing malicious
actions.
Efficiency: System calls allow programs to
perform complex tasks efficiently by
delegating them to the kernel.
There are several types of system calls, each serving Imagine a manager (OS) who assigns tasks
a different purpose. We will cover the five main (creates processes) to different workers.
types you should know for exams: If the task needs a new worker, the manager uses
fork() to hire them, and when the job’s done, the
1. Process Control manager calls exit() to dismiss the worker.
2. File Management
3. Device Management
4. Information Maintenance
5. Communication 2. File Management System Calls
Process control system calls are used for managing open(): Opens a file.
processes — starting, stopping, and controlling read(): Reads data from a file.
processes running on the system. write(): Writes data to a file.
close(): Closes an opened file.
⚙️Common Process Control Calls:
🧩 Example:
fork(): Creates a new process by duplicating
the current process. When you open a text file in a word processor:
exec(): Replaces the current process with a
new one. 1. The OS uses open() to access the file.
wait(): Makes the parent process wait until 2. The word processor uses read() to display
the child process finishes. its contents.
exit(): Terminates a process. 3. You edit and the OS uses write() to save
changes.
🧩 Example:
P a g e 24 | 60
Operating system Final NOTES by anees ahmad
💡 Definition:
Imagine two people (processes) communicating via When a user program needs to perform a privileged
phone lines (system calls). They can pass messages operation (such as accessing hardware resources or
through pipes or shared memory to coordinate interacting with the OS), it must use a system call
actions. to request that the OS execute the operation on its
behalf.
P a g e 26 | 60
Operating system Final NOTES by anees ahmad
o The system call's result is then Semantics refers to the meaning and behavior of a
returned to the user program (e.g., a system call. It defines what the system call does and
file handle, a success/error code). what its expected result is.
🧩 Example:
🧩 Analogy:
When a program calls read():
Think of ordering food in a restaurant. You (user)
make an order (system call). The waiter (OS) takes Expected Result: The OS reads data from
your order and brings the food back to you. You the file and returns the data to the program.
don’t interact directly with the kitchen (kernel); the If there’s an error (like trying to read from a
waiter does that on your behalf. non-existent file), the OS may return -1 with
an error code.
P a g e 27 | 60
Operating system Final NOTES by anees ahmad
Error Handling: Defines how errors are No clear separation between different OS
handled and reported to the user. components.
The OS is typically faster but harder to
maintain and debug.
Examples: MS-DOS, Unix (early versions)
🧩 Analogy:
3 OS Structures
🧠 Why It’s Important:
The structure of the OS defines how the OS
components are organized and how they interact Speed: Direct access to hardware and
with each other. There are several approaches to system resources.
structuring the OS, each with its own advantages Simplicity: Easier to develop for smaller or
and challenges. single-purpose systems.
💡 Key OS Structures:
💡 Definition: ⚙️Characteristics:
A simple structure OS is one where all OS Each layer communicates only with
components are bundled together in a single large adjacent layers, providing modularity and
program. The entire OS runs in kernel mode, isolation.
providing direct access to hardware and system More maintainable and easier to debug than
resources. a monolithic structure.
Example: XNU (used by macOS), Theos
⚙️Characteristics: (used in embedded systems).
P a g e 28 | 60
Operating system Final NOTES by anees ahmad
In a microkernel system, the core kernel provides
basic services like memory management and inter-
🧩 Example: process communication (IPC), but device drivers,
file systems, and network protocols are handled by
In the layered approach: user-level processes.
💡 Definition:
3️ Microkernel
A Virtual Machine (VM) is a virtualized
💡 Definition: environment that allows the OS to run multiple
guest operating systems on top of a host OS.
The Microkernel approach divides the OS into a
small, minimal kernel that handles only essential ⚙️Characteristics:
services (e.g., process management,
communication), while other services (like device A hypervisor (virtual machine monitor)
drivers, file systems) run in user space. manages the VM and allocates resources
between the host and guest operating
⚙️Characteristics: systems.
Each VM operates as if it is running on its
The kernel is minimal and focuses on own physical machine.
communication between processes. Examples: VMware, VirtualBox, KVM
Other OS services (e.g., device drivers) are
implemented as user-space programs,
making the system more flexible and secure.
Examples: Minix, QNX, Mach 🧩 Example:
P a g e 29 | 60
Operating system Final NOTES by anees ahmad
devices — and makes sure everything runs
smoothly.
🧠 Why It’s Important:
Think of it as the “manager” or “brain” of the
Isolation: Each VM is isolated from others, computer that controls how every part works
providing security and stability. together.
Flexibility: Multiple OS environments can
run on the same hardware, useful for testing
and development.
2. Major Components of Operating
System
P a g e 30 | 60
Operating system Final NOTES by anees ahmad
works behind the scenes. Example:
Without it, the system can’t function. When you open multiple apps, the OS decides how
much memory each will get.
Analogy:
2. Process Management Like a hotel manager assigning rooms (memory) to
guests (processes). When a guest leaves, the room is
Definition: freed for others.
It handles the creation, scheduling, and
termination of processes (programs in
execution).
4. File Management
Functions:
Definition:
Allocates CPU time to different processes It manages how data is stored, retrieved, and
Keeps track of process states (running, organized on storage devices (like hard drives or
waiting, etc.) USBs).
Prevents conflicts when multiple programs
run together Functions:
Definition:
It manages the computer’s primary memory
(RAM) — deciding which program gets how much 5. Device Management
memory and when.
Definition:
Functions: It controls all input and output (I/O) devices such
as keyboard, mouse, printer, and USB drives.
Keeps track of memory usage
Allocates and deallocates memory when Functions:
needed
Prevents one process from accessing Uses device drivers to communicate with
another’s memory area (security) hardware
Allocates devices to processes
P a g e 31 | 60
Operating system Final NOTES by anees ahmad
Handles input/output requests from +-----------------------------+
programs | Hardware
|
Example: +-----------------------------+
When you print a document, the OS sends it to the
printer using the proper driver.
4. Quick Summary Table
Analogy: Component Function Analogy
Like a translator — it helps software “talk” to
Core of OS, controls
hardware devices in their own language. Kernel Heart of OS
system
Examples
P a g e 33 | 60
Operating system Final NOTES by anees ahmad
Process scheduling mechanism 🔥 Mechanism vs Policy
Memory allocation mechanism Mechanism Policy
File access mechanism
Synchronization mechanism (semaphores, HOW to do something WHAT to do
locks)
Implementation detail Decision rule
📌 Mechanism does NOT decide:
Low-level High-level
who gets CPU Rarely changes Can change frequently
which process has priority
Simple Explanation
5. Language (Implementation
Policy = Rules / Decisions Language)
It answers: Definition
“What should be done?” Language refers to the programming languages
used to implement the OS.
Examples
Simple Explanation
Which process gets CPU first?
Which user can access a file? OS must be:
Which process has high priority?
Fast
📌 Policies can be: Efficient
Close to hardware
Fair
Priority-based So languages are chosen carefully.
Performance-based
Common Languages Used
use
1. What is UNIX? modify
distribute
Definition
Key Features of Linux
P a g e 35 | 60
Operating system Final NOTES by anees ahmad
Open source Feature UNIX Linux
Secure and stable
Multiuser & multitasking Developer AT&T Bell Labs Linus Torvalds
Runs on:
Year 1969 1991
o PCs
o Servers Source Code Closed source Open source
o Mobiles (Android)
o Supercomputers Cost Mostly paid Free
P a g e 36 | 60
Operating system Final NOTES by anees ahmad
6. Why Linux Became More Popular 1. What is UNIX Directory Structure?
Than UNIX?
Definition (Exam-ready)
Reasons (Bullet Points for Exams)
The UNIX directory structure is a hierarchical
Free and open source (tree-like) organization of files and directories
Strong community support starting from the root directory (/).
Easy to customize
Runs on cheap hardware Simple Explanation
Used in cloud, servers, Android
UNIX stores everything (files, folders, devices) in
one big tree 🌳
The root ( / ) is the starting point.
7. Security Comparison
Analogy
UNIX → Secure by design
Linux → Secure + frequent patches Think of UNIX like a family tree:
📌 Important Line for Exams: /= great-grandfather
Other directories = children & grandchildren
Linux security improves faster due to open-source
community.
2. Root Directory ( / )
8. Mnemonic to Remember
Very Important Point
Differences 🧠
/is the top-most directory
“UNIX is COSTLY & CLOSED, Linux is Every file and directory comes under /
FREE & FLEXIBLE”
📌 Exam Tip:
UNIX → Paid, Proprietary 👉 Root / ≠ root user
Linux → Free, Open Source (one is directory, other is admin user)
P a g e 37 | 60
Operating system Final NOTES by anees ahmad
Contains basic user commands /etc contains system-wide configuration files.
📌 Examples 🧠 Mnemonic
📌 Example
/sbin (System Binary)
/home/anees
📌 Purpose /home/student
reboot
shutdown /root
ifconfig
📌 Purpose
🧠 Mnemonic
Home directory of root user
SBIN = System Boss Instructions Needed
📌 Important
Different from /
/etc (Editable Text Configuration)
📌 Purpose
/usr (User System Resources)
Configuration files of system
📌 Purpose
📌 Examples
User-related programs and libraries
user accounts
passwords 📌 Contains
network settings
/usr/bin
📌 Important Exam Line
P a g e 38 | 60
Operating system Final NOTES by anees ahmad
/usr/lib USB
Keyboard
📌 Exam Tip
📌 Exam Line
Most applications are stored in /usr
UNIX treats everything as a file.
Log files
Mail files
Printer queues /proc (Process information)
🧠 Mnemonic 📌 Purpose
📌 Important
📌 Purpose
Hard disk
P a g e 39 | 60
Operating system Final NOTES by anees ahmad
5. Commands Used to Browse cd ..
cd ~
Directory Structure
📌 Special Symbols
Now the most practical part 👇
. → current directory
.. → parent directory
📌 Use
4. tree
Shows current directory
📌 Use
📌 Example
Displays directory structure like a tree 🌳
pwd
tree /
/home/anees
📌 Exam Tip
2. ls (List) Not always installed by default.
📌 Use
🧠 Mnemonic
📌 Use
✅ Definition
6. Important Comparison (Exam Alert
A process is a program in execution, along with
🚨)
all the resources required to execute it.
/bin vs /sbin 📌 Very important line (write exactly like this):
B → /bin
S → /sbin 🔹 Program vs Process (Must-know
E → /etc
H → /home
comparison)
U → /usr
V → /var Program Process
T → /tmp Passive Active
D → /dev
L → /lib Stored on disk Exists in memory
P → /proc
No execution Executing
P a g e 41 | 60
Operating system Final NOTES by anees ahmad
🔹 What Does a Process Contain? (VERY 2️A. CPU-Bound Process (IN DETAIL)
IMPORTANT)
✅ Definition
A process is not only code. It contains:
A CPU-bound process spends most of its time
1. Text section – program instructions executing on the CPU.
2. Data section – global variables
3. Heap – dynamic memory
4. Stack – function calls, local variables
5. CPU context – registers, program counter 🔹 Characteristics
6. Resources – files, I/O devices
✔️Long CPU bursts
📌 Writing these points gives extra marks. ✔️Very few I/O operations
✔️Performance depends on CPU speed
🔹 Real-Life Analogy
🔹 Examples
📘 Recipe vs Cooking
Mathematical calculations
Recipe book = Program Video rendering
Cooking in kitchen = Process Scientific simulations
Ingredients + stove + cook = Resources Encryption algorithms
✅ Definition
P a g e 42 | 60
Operating system Final NOTES by anees ahmad
An I/O-bound process spends most of its time Feature CPU-Bound I/O-Bound
waiting for I/O operations.
Example Calculations File read
🔹 Analogy
🟢 Step 2: Process Creation
📞 Person waiting for calls
OS creates a PCB
Short talking Assigns PID
Long waiting Allocates memory & resources
📌 Program → Process
🧠 Mnemonic
P a g e 43 | 60
Operating system Final NOTES by anees ahmad
🟢 Step 5: Execution Cycle 🧠 MASTER MNEMONICS (REVISION
GOLD)
Process alternates between:
🔹 Process Definition
CPU burst
I/O burst
P-E-R-C
👉 Program Execution Requires Context
📌 If I/O needed → process blocked
📌 CPU given to another process
🔹 CPU vs I/O
many processes
only one CPU
4 Why This Mechanism Is Important?
So the OS must:
Because it allows:
✔️Multitasking track what each process is doing
✔️CPU sharing decide who gets the CPU
✔️High utilization
✔️Fair execution ➡️That’s why process states [Link] states
represent the current status of a process during its
execution.
P a g e 44 | 60
Operating system Final NOTES by anees ahmad
3️Explanation of Each Process State Multiple apps open
(DETAILED) Waiting for CPU turn
🟢 1. NEW STATE
📝 Exam Point
🔹 Meaning In the Ready state, the process is prepared to
execute and waiting for CPU allocation.
Process is being created
OS is:
o assigning Process ID (PID)
o creating PCB 🔴 3. RUNNING STATE
o allocating initial resources
🔹 Meaning
📌 Not yet in main memory
Process is currently executing
CPU registers are active
Instructions are being executed
🧠 Example
📌 Only ONE process can be running per CPU
You double-click an application → process enters
NEW state
🧠 Example
📝 Exam Point A program currently using CPU
🟡 2. READY STATE In the Running state, the process has been assigned
the CPU and is executing instructions.
🔹 Meaning
P a g e 46 | 60
Operating system Final NOTES by anees ahmad
7 Why PCB is Needed? 🔹 5. Memory Management Information
🔹 4. Scheduling Information
🔹 Step 2: Process Execution
Priority
CPU usage CPU scheduler selects process
Queue pointers PCB loaded into CPU
Process enters Running state
P a g e 47 | 60
Operating system Final NOTES by anees ahmad
🔥 Key Exam Difference: PCB vs
🔹 Step 3: Context Switch Occurs Program
PCB Program
Triggered by: Data structure File
🔹 Simple Explanation
P a g e 48 | 60
Operating system Final NOTES by anees ahmad
Because:
📌 Exam Point:
2 Why Are Scheduling Queues
Job queue controls the degree of
Needed? multiprogramming.
Scheduling queues help OS to:
🧠 Mnemonic
👉 J R D — Job Ready Device 5 READY QUEUE (IN DETAIL)
✅ Definition
4 JOB QUEUE (IN DETAIL)
The Ready Queue contains processes that are:
in main memory
✅ Definition ready to execute
waiting only for CPU
The Job Queue contains all processes that are
created in the system but are not yet loaded into
main memory.
P a g e 49 | 60
Operating system Final NOTES by anees ahmad
🔹 Key Characteristics 🔹 Examples
Processes in ready queue have all resources except Each I/O device has its own device queue.
CPU.
🔹 Analogy
🔹 What Happens Here?
🖨️Printer line
Process enters memory Only one job prints at a time
Waits in ready queue
CPU scheduler selects one
Process moves to Running state
7 PROCESS MIGRATION
BETWEEN QUEUES (VERY
🔹 Analogy IMPORTANT)
🚦 Cars waiting at traffic signal This explains HOW processes move between
All ready, waiting for green light (CPU) queues during execution.
P a g e 50 | 60
Operating system Final NOTES by anees ahmad
🟢 Step 3: CPU Allocation 1. Job Queue
o Stores all new processes
Short-term scheduler selects process o Controls system load
Process moves from Ready Queue → 2. Ready Queue
Running o Holds processes ready to run
o CPU scheduling happens here
3. Device Queue
o Handles I/O waiting
🟢 Step 4: I/O Request o Prevents CPU waste
4. Schedulers
Running process requests I/O o Long-term → selects jobs
CPU released o Short-term → selects CPU process
Process moves to Device Queue o I/O scheduler → manages device
queues
P a g e 51 | 60
Operating system Final NOTES by anees ahmad
🔚 FINAL SUMMARY
2️Why Scheduling is Needed?
Process scheduling queues are used by the operating
system to manage process execution efficiently.
Processes move between job, ready, and device Scheduling helps to:
queues based on CPU allocation and I/O requests,
ensuring proper scheduling and resource utilization. maximize CPU utilization
improve system performance
ensure fairness
support multitasking
reduce waiting time
SCHEDULING (IN OPERATING
SYSTEM) 📌 Without scheduling → system becomes slow and
unfair ❌
1️What is Scheduling?
3️Types of Scheduling (VERY
✅ Definition
IMPORTANT)
Scheduling is the process by which the operating
system decides which process gets the CPU, There are three main types:
when, and for how long.
1. Long-Term Scheduling
📌 Golden exam line: 2. Short-Term Scheduling
3. Medium-Term Scheduling
Scheduling is the mechanism used by the operating
system to manage the execution of multiple 🧠 Mnemonic
processes by allocating CPU time. 👉 L-S-M → Large Small Medium
(helps remember the order)
🔹 Simple Explanation
4 LONG-TERM SCHEDULING
Many processes want to use CPU (JOB SCHEDULER)
CPU can run only one process at a time
➡️OS acts like a manager and schedules
them.
✅ Definition
🔹 How It Works
🧠 Analogy
🔹 Example
📌 Exam Tip
Choosing which app runs next on CPU
Long-term scheduler balances CPU-bound and I/O-
bound processes.
P a g e 53 | 60
Operating system Final NOTES by anees ahmad
🧠 Analogy 2. Medium-term scheduler swaps some out
3. Frees memory
🚦 Traffic signal 4. Later swaps them back
Executes occasionally
📌 Exam Tip Less frequent than short-term
✅ Definition
📌 Exam Tip
Medium-term scheduling temporarily removes
processes from memory to reduce system load and Medium-term scheduling helps prevent thrashing.
later brings them back.
7 COMPARISON TABLE
🔹 Key Concept: Swapping Medium-
Feature Long-Term Short-Term
Term
Process removed → suspended
Later reloaded → resumed CPU
Also called Job Scheduler Swapper
Scheduler
Which Which
Which jobs enter
🔹 What It Controls Decides
memory
process gets process to
CPU suspend
✔️Memory usage
✔️System performance CPU Memory
Controls Multiprogramming
allocation load
P a g e 54 | 60
Operating system Final NOTES by anees ahmad
Context Switching is the process by which the 1. CPU Registers – current calculations
operating system saves the state of a currently 2. Program Counter – next instruction to
running process and loads the state of the next execute
process to be executed by the CPU. 3. Stack Pointer – function calls, local
variables
📌 Golden line for exams: 4. Memory management info – page/segment
tables
5. Process state – Running, Ready, Waiting
P a g e 55 | 60
Operating system Final NOTES by anees ahmad
📌 Without this, the process would lose progress Allows CPU to share time fairly among
when switched out. processes
Prevents CPU idling
1. CPU Preemption – higher priority process Overhead – CPU is doing no useful work
arrives while switching
2. I/O Request – process needs I/O device → Frequent switches → performance drops
blocked Requires fast memory access to PCB
3. Interrupts – timer or hardware interrupts
4. Process Termination – running process 📌 Exam Tip: Always mention “context switch
finishes overhead”
“Save-Load-Resume”
🔹 Exam Diagram Save old, Load new, Resume execution
Running Process A
↓ (Interrupt / I/O)
Save State → PCB A 🔚 Final Summary
↓
Load State → PCB B Context switching is the process of saving the state
↓ of a running process and loading the state of another
Running Process B process to allow multitasking. It ensures CPU
utilization and fairness but introduces overhead.
Enables multitasking
P a g e 56 | 60
Operating system Final NOTES by anees ahmad
7 Exam Tip
📌 Shared with other threads of the same process: 🔹 Step 2: Thread Scheduling
P a g e 59 | 60
Operating system Final NOTES by anees ahmad
9 Real-Life Example
🔚 Final Summary
P a g e 60 | 60