SUBMITTED BY:
NAME: HAMMAD ALI
ROLL NO: 23014198-152
SECTION: SE-23-C
COURSE TITLE: OPERATING
SYSTEM
COURSE CODE: SE-205
SUBMITTED TO:
MAM. AYESHA NOREEN
QUESTION#01:
Operating systems use data structures such as linked lists, queues, stacks, trees, hash tables, and
bitmaps.
Explain their applications in OS, along with their benefits and drawbacks.
Identify which are most commonly used in modern operating systems.
ANSWER:
1. Linked Lists
Where OS uses them:
Usage Example
Process management Ready list of processes/threads
Memory management Linked list of free/allocated memory blocks
File systems Directory entries in older/simple file systems
Benefits
Dynamic memory allocation (no fixed size)
Easy insertion/deletion (suitable for frequently changing lists)
Drawbacks
Slow traversal (no direct indexing)
Extra memory for pointers
2. Queues
Where OS uses them:
Usage Example
CPU Scheduling Ready queue, waiting queue
I/O Management I/O request queue
Interrupt Handling Interrupt service queue
Benefits
First-Come-First-Served (fair)
Simple to implement
Drawbacks
Not priority-aware by default
Can cause starvation in high load unless priority queues are used
Stacks
Where OS uses them:
Usage Example
Function Calls Kernel stack for system calls
Interrupt Handling Saving CPU registers return address
Context switching Storing execution states
Benefits
Fast push/pop O(1)
Perfect for LIFO (last-in, first-out) behavior
Drawbacks
Fixed size in kernel (risk of stack overflow)
Not useful for random access
4. Trees (especially Balanced Trees like Red-Black Trees)
Where OS uses them:
Usage Example
Process lookup Linux uses Red-Black Tree for task scheduling (CFS)
Virtual Memory region management (VMA) uses AVL/RB trees
memory
File systems Directory indexing in modern FS (ext4, NTFS, APFS use B-
Trees/B+Trees)
Benefits
Very fast lookup, insert, delete (O(log n))
Scales well for large OS data
Drawbacks
Complex implementation
More memory overhead compared to lists
5. Hash Tables
Where OS uses them:
Usage Example
Caching Page cache, buffer cache
File lookup Linux inode/dentry caching
Kernel objects fast PID, UID etc mapping
Benefits
Extremely fast lookup O(1) average
Ideal for heavily used OS subsystems
Drawbacks
Collisions can slow performance
Requires good hashing and rehashing strategy
6. Bitmaps
Where OS uses them:
Usage Example
Memory Management Tracking free/used RAM frames
Disk Management Allocation of disk blocks (FAT/ext4)
Process IDs Checking available PID bitmap
Benefits
Very space efficient
Very fast to check free/used resources
Drawbacks
Checking first free bit can still be O(n)
Hard to resize
So which data structures are MOST used in modern OS?
Data Structure Modern OS importance
Hash Tables ⭐ Very widely used (for caching, lookup)
Balanced Trees (RB Tree / B+ Tree) ⭐ Used heavily in scheduling + filesystems
Queues ⭐ Used in CPU & I/O scheduling
Bitmaps ⭐ Used in memory & disk management
Linked Lists ✔ Common but slowly replaced by trees for speed
Stacks ✔ Used internally for calls & interrupts
Different types of systems — such as personal computers, mobile devices, servers, supercomputers,
and embedded systems — often use different operating systems.
List the types of operating systems commonly used in these systems today.
Explain why each type of OS is suitable for its environment.
ANSWER:
Types of Systems & OS Commonly Used Today
System Type Common OS Used Why This OS is Suitable
Personal Computers Windows, macOS, Linux User-friendly, supports
(Desktops/Laptops) (Ubuntu/Fedora) multitasking, rich GUI, large
application support
Mobile Devices Android, iOS Optimized for touch interface,
(Smartphones/Tablets) battery efficient, secure app
sandboxing
Servers (Data centers / Linux (Ubuntu Server, High performance, reliability,
Enterprise / Cloud) CentOS, RHEL), better security, remote
Windows Server administration, supports
thousands of simultaneous users
Supercomputers / HPC Linux-based HPC Extremely scalable, supports
systems distributions (CentOS, parallel processing (MPI),
SUSE, Cray Linux) optimized for scientific
computation
Embedded Systems (IoT, RTOS (FreeRTOS, Real-time performance, low
routers, appliances, cars) VxWorks), Embedded memory footprint, stability, runs
Linux, QNX on small hardware
Why These OS Types Are Suitable (Detailed Explanation)
Personal Computers
OS examples: Windows 10/11, macOS, Linux
Suitability:
o Designed for interactive use
o Strong GUI and multitasking
o Supports productivity apps (MS Office), media, gaming
o Easy driver and hardware support
Mobile Devices
OS examples: Android, iOS
Suitability:
o Optimized for touchscreen
o Efficient battery and memory management
o Built with app sandboxing → more security
o Supports wireless connectivity and sensors (GPS, gyroscope, etc.)
Servers
OS examples: Linux Server (Ubuntu/RHEL), Windows Server
Suitability:
o Built for 24/7 uptime
o High concurrency → can handle thousands of requests
o Strong networking and security
o Easily configurable through terminal/CLI
o Linux is open-source → customizable & cost-effective
Supercomputers
OS examples: Linux-based HPC distros (SUSE, Cray Linux)
Suitability:
o Optimized for parallel computation
o Works with clusters and distributed memory
o Supports MPI / GPU computation
o Extremely stable under heavy workloads
Embedded Systems
OS examples: FreeRTOS, QNX, VxWorks, Embedded Linux
Suitability:
o Real-time response (e.g., airbags, medical devices)
o Very small memory footprint
o Works on microcontrollers and low-power CPUs
o High stability & reliability
QUESTION#03:
When a file is deleted in an operating system, it often remains on the storage device until it is
overwritten by new data.
Explain how the OS marks files as deleted internally.
Describe why deleted data can sometimes be recovered using recovery tools.
Discuss the limitations of file recovery and situations where recovery is not possible
ANSWER:
How the OS Marks Files as Deleted Internally
When a file is deleted, the OS does not immediately erase the file’s data from storage.
Instead, it:
1. Removes the file entry from the directory table
2. Marks the file’s occupied space as “free” or “available for reuse”
3. The actual data blocks remain untouched until overwritten
Examples by file system:
File System What happens when deleting
FAT32 First character of filename is replaced with a special marker
NTFS (Windows) Directory record marked as unused & clusters marked free in bitmap
EXT4 (Linux) inode unlinked from directory but data blocks remain
So internally, only references (pointers) to the data are deleted, not the data itself.
Why Deleted Data Can Be Recovered
Because the actual data remains on the disk after deletion, recovery tools can scan:
Raw disk sectors
Unused file system entries
Inode and cluster tables
These tools restore files by rebuilding pointers to the original data blocks.
In simple words:
“The file is not gone — only its address is forgotten by the OS.”
Until new data overwrites that area, the old data is still recoverable.
Limitations of File Recovery (When It Fails)
Recovery is not always possible. It fails when:
Situation Why Recovery Fails
Data has been overwritten Original content is replaced by new files
SSD with TRIM enabled Blocks are immediately cleared by controller
Secure delete / shredding tools File is overwritten multiple times intentionally
Full disk encryption Without key, raw data is unusable
Damaged file system metadata Recovery tools cannot find file structure