Operating Systems-II
📌 Chapter 1: Process Deadlocks – Short Notes
📌 System Model
A system consists of multiple processes that require resources (CPU, memory, I/O) for
execution. Resources are either preemptable (can be taken away) or non-preemptable
(cannot be forcibly taken). Deadlocks occur when processes wait indefinitely for resources
held by others.
📌 Deadlock Characterization
1️⃣ Necessary Conditions (Coffman’s Conditions)
A deadlock occurs when all of these four conditions hold:
1. Mutual Exclusion – A resource can only be used by one process at a time.
2. Hold and Wait – A process holding a resource waits for additional resources.
3. No Preemption – Resources cannot be forcibly taken from a process.
4. Circular Wait – A circular chain of processes exists where each process waits for a
resource held by another.
2️⃣ Resource Allocation Graph (RAG)
A graph-based representation of processes and resources.
Nodes: Represent Processes (P1, P2, …) and Resources (R1, R2, …).
Edges:
Assignment Edge (R → P): Resource assigned to a process.
Request Edge (P → R): Process waiting for a resource.
Cycle in RAG:Indicates a possible deadlock.
Single instance per resource: Cycle guarantees deadlock.
Multiple instances: Cycle may or may not lead to deadlock.
📌 Deadlock Handling Methods
1️⃣ Deadlock Prevention (Eliminate Necessary Conditions)
🔹 Ensure that at least one of the four necessary conditions never holds:
Eliminate Mutual Exclusion: Not practical for non-sharable resources.
Eliminate Hold and Wait: Allocate all resources before execution (low resource
utilization).
Eliminate No Preemption: If a process requests a resource, preempt the existing one.
Eliminate Circular Wait: Impose an ordering on resources and require processes to
request them in order.
2️⃣ Deadlock Avoidance (Safe State Concept)
🔹 The system avoids deadlock by checking resource allocation before granting requests.
🔹 Safe State: If there exists a sequence of process execution where every process can finish
without deadlock, the system is in a safe state.
✅ Safe State = No Deadlock
❌ Unsafe State = Possible Deadlock
Resource Allocation Graph Algorithm
Used if each resource has only one instance.
Removes request edges dynamically to check if all processes can complete execution
safely.
Banker’s Algorithm (Multiple Instances)
Extends Safe State Concept for multiple instances of a resource.
Steps:
1. Calculate Need = Max – Allocated.
2. Check if a process can finish with available resources.
3. If yes, release resources and continue until all processes finish.
4. If any process is left, the system is in an unsafe state → Potential Deadlock.
📌 Deadlock Detection
🔹 If no prevention or avoidance method is used, the system should detect deadlocks using:
1️⃣ Resource Allocation Graph (Single Instance per Resource)
Check for cycles → If found, deadlock detected.
2️⃣ Banker’s Algorithm (Multiple Instances)
Apply a similar algorithm to Safe State check to find a process sequence that completes.
If none exist, deadlock detected.
📌 Recovery from Deadlock
🔹 Once a deadlock is detected, the system must recover using:
1️⃣ Process Termination
✔️ Abort all deadlocked processes → Quick but costly.
✔️ Abort processes one by one until deadlock is resolved → Needs careful selection.
2️⃣ Resource Preemption
✔️ Select a process and preempt its resources to break the deadlock.
✔️ Issues to consider:
Rollback: Process may have to restart.
Starvation: Some processes may always be preempted.
📌 Quick Revision Table for Exams
Topic Key Points
Deadlock Process indefinitely waiting for
resources held by others.
Necessary Conditions Mutual Exclusion, Hold & Wait, No
Preemption, Circular Wait.
RAG Graph with process & resource nodes.
Cycle = Possible Deadlock.
Deadlock Prevention Remove one of the necessary
conditions.
Deadlock Avoidance Use Safe State, Resource Allocation
Graph, Banker’s Algorithm.
Deadlock Detection Check cycles in RAG or apply detection
algorithm.
Recovery Methods Terminate processes or Preempt
resources.
📌 Chapter 2: File System Management
📌 1. File Concept
A file is a collection of related data stored on disk. It has:
✔️ Logical structure (e.g., text, binary, executable).
✔️ Physical structure (stored in blocks on a disk).
📌 2. File Attributes
Each file has metadata (attributes) stored in a File Control Block (FCB):
Attribute Description
Name Human-readable file name.
Type Text, binary, image, executable, etc.
Location Disk address of file blocks.
Size File size in bytes.
Protection Permissions (read, write, execute).
Timestamps Creation, last modified, last accessed.
📌 3. File Operations
Basic operations performed on files:
1️⃣ Create – Allocate disk space & assign a name.
2️⃣ Open – Load file attributes into memory.
3️⃣ Read – Retrieve data from a file.
4️⃣ Write – Modify file content.
5️⃣ Append – Add new data at the end.
6️⃣ Delete – Remove file entry and deallocate storage.
7️⃣ Close – Remove file from memory when done.
📌 4. Access Methods
Ways to read and write data in a file.
Access Method Description
Sequential Access Read data in order from start to end (e.g.,
text files).
Direct Access Access any block randomly using an index
(e.g., database files).
Other Methods - Indexed Access: Uses an index table to
locate records.
- Hashed Access: Uses a hash function for
fast lookup.
📌 5. Directory Overview
A directory stores file names and metadata for organization.
Types of Directory Structures
Directory Type Description
Single-Level Directory All files stored in one directory. Easy but
creates name conflicts.
Two-Level Directory Separate directory for each user (prevents
name conflicts).
Tree-Structure Directory Hierarchical folders like Windows/Linux.
Efficient but complex.
Acyclic Graph Directory Allows file sharing using links but avoids
cycles.
General Graph Directory Allows multiple parent directories, but
cycles may form.
✅ Tree-structured and Acyclic Graph directories are most common!
📌 6. File Allocation Methods
How files are stored on disk.
1️⃣ Contiguous Allocation
File stored in continuous disk blocks.
Fast but leads to fragmentation.
2️⃣ Linked Allocation
Each file is a linked list of disk blocks.
No fragmentation, but slow random access.
3️⃣ Indexed Allocation
Index block stores pointers to file blocks.
Fast and flexible, but extra index storage required.
Method Advantages Disadvantages
Contiguous Fast access External fragmentation
Linked No fragmentation Slow access
Indexed Direct access Needs extra index block
✅ Indexed allocation is commonly used in modern OS!
📌 7. Free Space Management
How the OS tracks free disk space.
1️⃣ Bit Vector
Each bit = 0 (free) or 1 (used) in a bitmap.
Efficient but requires extra storage.
2️⃣ Linked List
Free blocks stored as a linked list.
Saves space but slow searching.
3️⃣ Grouping
First free block stores addresses of more free blocks.
Faster than linked list.
4️⃣ Counting
Store starting block + number of free blocks in a row.
Reduces list size, improving efficiency.
5️⃣ Space Maps
Used in advanced file systems like ZFS.
Compressed structure for tracking free space efficiently.
📌 Quick Revision Table for Exams
Topic Key Points
File Collection of related data stored on disk.
File Attributes Name, Type, Size, Permissions,
Timestamps.
File Operations Create, Open, Read, Write, Append, Delete.
Access Methods Sequential (ordered reading) vs. Direct
(random access).
Directory Structures Single-Level, Two-Level, Tree, Acyclic,
General Graph.
Allocation Methods Contiguous (fast but fragmented), Linked
(slow but flexible), Indexed (direct access).
Free Space Management Bit Vector, Linked List, Grouping, Counting,
Space Maps.
📌 1. Contiguous Allocation – Numerical Example
Problem:
A file of size 800 KB needs to be stored on a disk where each block is 100 KB. The following
free blocks are available:
Block Number Size (KB)
1 200
2 500
3 300
4 800
5 1000
📌 Find: Which block will be selected using Best Fit, First Fit, and Worst Fit?
Solution:
1️⃣ Best Fit: (Smallest available block that fits the file)
Block 3 (300 KB) is too small.
Block 2 (500 KB) is too small.
Block 4 (800 KB) is selected. ✅
2️⃣ First Fit: (First block that fits the file)
Block 1 (200 KB) is too small.
Block 2 (500 KB) is too small.
Block 4 (800 KB) is selected. ✅
3️⃣ Worst Fit: (Largest available block)
Block 5 (1000 KB) is selected. ✅
📌 Conclusion:
Best Fit = 800 KB block (Minimum wastage).
First Fit = 800 KB block (First available).
Worst Fit = 1000 KB block (Maximum wastage).
📌 2. Linked Allocation – Numerical Example
Problem:
A file of 5 blocks (A, B, C, D, E) is stored using linked allocation. The following blocks are
available in the disk:
File Block Stored in Disk Block
A 10
B 5
C 18
D 7
E 12
📌 Find: The Linked List Representation of the file.
Solution:
Each block stores a pointer to the next block.
The file is stored as:
📌 File Structure in Disk (Linked List Representation)
Block No. Next Pointer
10 5
5 18
18 7
7 12
12 NULL
📌 Conclusion:
✔️ Advantage: No external fragmentation.
✔️ Disadvantage: Slow access (must traverse pointers).
📌 3. Indexed Allocation – Numerical Example
Problem:
A file of 6 blocks is stored using Indexed Allocation. The index block is stored at Block 20 and
the file data is stored in:
File Block Stored in Disk Block
A 8
B 19
C 12
D 25
E 14
F 30
📌 Find: How the file is represented in Indexed Allocation.
Solution:
Index Block (Stored in Block 20) holds addresses of all file blocks.
📌 Index Block Structure (Block 20)
File Block Disk Address
A 8
B 19
C 12
D 25
E 14
F 30
✔️ Advantage: Fast random access (Directly access any block).
❌ Disadvantage: Requires extra index block storage.
📌 Chapter 3: Disk Scheduling –
📌 1. Overview of Disk Scheduling
Disk scheduling refers to the efficient order in which disk requests are processed to minimize
seek time (time taken for the read/write head to move).
Disk Parameters:
Seek Time (Ts) → Time to move the disk head to the requested track.
Rotational Latency (Tr) → Time for the sector to reach the read/write head.
Transfer Time (Tt) → Time to transfer data from disk to memory.
📌 Total Time = Seek Time + Rotational Latency + Transfer Time
📌 2. Disk Structure
A hard disk is divided into platters.
Each platter has tracks, which are divided into sectors.
The read/write head moves over the tracks to access data.
📌 Key Components:
Component Description
Platter Circular disk storing data.
Track Circular path on a platter.
Sector Smallest storage unit on a track.
Cylinder A set of tracks stacked across multiple
platters.
Read/Write Head Reads and writes data.
📌 3. Disk Scheduling Algorithms
Disk scheduling determines the order of pending I/O requests to minimize seek time.
📌 Example Problem
Given a disk with tracks 0 to 199.
The disk head is at track 50.
The following requests are pending: 98, 183, 37, 122, 14, 124, 65, 67.
Let's apply different scheduling algorithms!
1️⃣ FCFS (First Come, First Serve)
Processes requests in order received.
Simple but high seek time.
📌 Order: 50 → 98 → 183 → 37 → 122 → 14 → 124 → 65 → 67
✔️ Advantage: Simple, fair scheduling.
❌ Disadvantage: High seek time if requests are scattered.
2️⃣ SSTF (Shortest Seek Time First)
Selects the closest track to the current position.
Minimizes seek time, but may cause starvation.
📌 Order: 50 → 65 → 67 → 37 → 14 → 98 → 122 → 124 → 183
✔️ Advantage: Faster than FCFS.
❌ Disadvantage: Starvation issue (far requests may wait too long).
3️⃣ SCAN (Elevator Algorithm)
Moves in one direction until the last request, then reverses.
Prevents starvation.
📌 Order (Moving Right): 50 → 65 → 67 → 98 → 122 → 124 → 183 → 199 → 14 → 37
✔️ Advantage: Avoids starvation.
❌ Disadvantage: Longer wait for some requests.
4️⃣ LOOK Scheduling
Similar to SCAN but stops at the last request (does not go to the end).
📌 Order: 50 → 65 → 67 → 98 → 122 → 124 → 183 → 14 → 37
✔️ Advantage: Less unnecessary movement than SCAN.
❌ Disadvantage: Can still have delays for some requests.
📌 4. Disk Management
Disk management involves formatting, partitioning, and error handling.
1️⃣ Formatting
Low-Level Formatting: Divides disk into sectors.
High-Level Formatting: Creates file system (FAT, NTFS, ext4).
2️⃣ Partitioning
Divides disk into logical sections (C:, D: drives).
3️⃣ Error Handling
Bad Block Management: Detects and maps bad disk sectors.
📌 Quick Revision Table for Exams
Algorithm Working Pros Cons
FCFS Process requests in Simple, fair High seek time
order
SSTF Choose the closest Minimizes seek time Starvation issue
request first
SCAN Moves in one Avoids starvation More seek time
direction, then
reverses
LOOK Like SCAN, but Reduces Longer waits for
stops at last unnecessary some
request movement
📌 Chapter 4: Introduction to Distributed Operating
Systems & Architecture – Exam Notes
📌 1. What is a Distributed System?
A distributed system is a collection of independent computers that appear to users as a
single system by communicating over a network.
📌 Key Features:
✔️ Multiple Nodes: Multiple computers work together.
✔️ Resource Sharing: CPU, memory, storage, and printers are shared.
✔️ Fault Tolerance: System continues running if one node fails.
✔️ Scalability: Can add more nodes easily.
✔️ Concurrency: Multiple processes run simultaneously.
📌 2. Design Goals of Distributed Systems
Design Goal Description
Transparency Users should not notice system
complexity.
Reliability System continues functioning despite
failures.
Scalability System should handle increasing load
efficiently.
Concurrency Multiple processes should run without
conflicts.
Security Secure data transmission and access
control.
Openness Support for different hardware and
software.
📌 3. Types of Distributed Systems
Type Example
Distributed Computing System Cloud computing, parallel processing
Distributed Information System Banking, e-commerce platforms
Distributed Pervasive System IoT (Internet of Things), smart homes
📌 Examples:
✔️ Google Cloud (Distributed Computing)
✔️ Bank ATM Network (Distributed Information)
✔️ Smart Home IoT System (Distributed Pervasive)
📌 4. Architectural Styles of Distributed Systems
1️⃣ Layered Architecture
Organized into layers (e.g., Presentation, Business Logic, Data).
Example: OSI Model (7 layers).
✔️ Advantage: Easy to manage and debug.
❌ Disadvantage: Higher latency due to multiple layers.
2️⃣ Object-Based Architecture
Uses objects that communicate using messages.
Example: CORBA (Common Object Request Broker Architecture).
✔️ Advantage: Reusable components, flexible design.
❌ Disadvantage: Complex implementation.
3️⃣ Resource-Centered Architecture
Resources (e.g., databases, printers) are centrally managed.
Example: Cloud storage, Distributed databases.
✔️ Advantage: Efficient resource sharing.
❌ Disadvantage: High network traffic.
📌 5. System Architecture of Distributed Systems
1️⃣ Centralized Organization
One central server handles all requests.
Example: Traditional client-server model (e.g., Websites).
✔️ Advantage: Simple and secure.
❌ Disadvantage: Single point of failure.
2️⃣ Decentralized Organization
No single central server.
Example: Blockchain, BitTorrent.
✔️ Advantage: High fault tolerance.
❌ Disadvantage: More complex to manage.
3️⃣ Peer-to-Peer (P2P) Systems
All nodes act as both clients and servers.
Example: Bitcoin, Skype, File-sharing networks (Napster, BitTorrent).
✔️ Advantage: No dependency on central server.
❌ Disadvantage: Harder to secure.
4️⃣ Hybrid Architecture
Combination of Centralized & Decentralized models.
Example: Google Drive (Centralized storage + P2P sync).
✔️ Advantage: Optimized for performance.
❌ Disadvantage: Complexity in design.
📌 6. Example Architectures
1️⃣ Network File System (NFS)
Allows multiple computers to share files over a network.
Used in Linux, Unix environments.
✔️ Advantage: Centralized file access.
❌ Disadvantage: Performance drops if network is slow.
2️⃣ Web-Based Distributed Systems
Example: Google Drive, Dropbox, Amazon Web Services (AWS).
Uses web servers + cloud storage for distributed access.
✔️ Advantage: Accessible from anywhere.
❌ Disadvantage: Dependent on internet availability.
📌 Quick Revision Table for Exams
Concept Key Points
Distributed System Multiple computers working as a single
unit.
Design Goals Transparency, Reliability, Scalability,
Security.
Types of Distributed Systems Computing, Information, Pervasive.
Architectural Styles Layered, Object-based, Resource-
centered.
System Architectures Centralized, Decentralized, P2P, Hybrid.
Examples NFS, Web-based systems (AWS, Google
Drive).
📌 Chapter 5: Mobile Operating Systems –
Exam Notes
📌 1. Introduction to Mobile Operating Systems
A Mobile Operating System (OS) is software that manages the hardware and software of a
mobile device (smartphones, tablets, PDAs, smartwatches).
📌 Key Functions:
✔️ Manages hardware – CPU, battery, memory, sensors.
✔️ Controls user interface – Touch, voice commands.
✔️ Handles apps & background processes.
📌 Examples of Mobile OS:
✔️ Android – Google’s open-source mobile OS.
✔️ iOS – Apple’s mobile OS for iPhones.
✔️ Windows Mobile – Microsoft’s discontinued OS.
📌 2. Features of Mobile Operating Systems
Feature Description
Touch Interface Supports gestures like tap, swipe, pinch.
Wireless Connectivity Supports WiFi, Bluetooth, NFC, GPS.
Power Management Optimizes battery life using CPU
scheduling.
App Store Users can download/install apps.
Security Features Encryption, biometric authentication.
Multitasking Runs multiple apps in the background.
📌 Example: Android uses Doze Mode for power saving.
📌 3. Special Constraints & Requirements of Mobile OS
📌 Mobile OS must handle:
✔️ Limited Battery Life – Power-efficient resource allocation.
✔️ Limited Memory & Storage – Optimized RAM and disk usage.
✔️ Touchscreen Input – UI designed for fingers (not mouse/keyboard).
✔️ Network Variability – Switching between WiFi, 4G, 5G.
✔️ Security Risks – Protection from malware & unauthorized access.
📌 Example: iOS sandboxing isolates apps for security.
📌 4. Special Service Requirements of Mobile OS
✔️ Context Awareness: Detects location, movement, and network conditions.
✔️ Real-Time Processing: Handles real-time calls, notifications, and GPS tracking.
✔️ Adaptive Resource Allocation: Adjusts CPU/GPU usage based on battery status.
📌 Example: Google’s Adaptive Battery in Android optimizes battery usage based on user
habits.
📌 5. ARM & Intel Architectures – Power Management
1️⃣ ARM Architecture (Advanced RISC Machine)
✔️ Designed for mobile devices → Low power consumption.
✔️ Uses RISC (Reduced Instruction Set Computing) → Faster execution.
✔️ Common in smartphones, tablets, IoT devices.
📌 Example: Qualcomm Snapdragon (ARM-based processor).
2️⃣ Intel Architecture (x86-based)
✔️ Used in high-performance devices (laptops, some tablets).
✔️ Higher power consumption than ARM.
✔️ Supports complex computing operations.
📌 Example: Intel Atom processors in Windows tablets.
📌 Comparison:
Feature ARM Intel
Power Consumption Low (efficient) High (power-hungry)
Performance Optimized for mobile Faster but uses more
power
Usage Smartphones, tablets Laptops, high-end tablets
📌 6. Mobile OS Architectures
Component Function
Kernel Core of OS, manages CPU, memory, I/O
devices.
Middleware Manages API services (Bluetooth, WiFi,
Sensors).
Application Layer Interface for users (apps, UI).
📌 Example:
✔️ Android Kernel – Based on Linux Kernel.
✔️ iOS Kernel – Based on XNU Kernel (Unix-based).
📌 7. Commercial Mobile Operating Systems
1️⃣ Android (Google)
✔️ Open-source, Linux-based.
✔️ Customizable (used by Samsung, OnePlus, Xiaomi).
✔️ Uses APK format for apps.
📌 Example: Samsung One UI (custom Android version).
2️⃣ iOS (Apple)
✔️ Closed-source, Unix-based (XNU Kernel).
✔️ Highly secure (sandboxing, Face ID).
✔️ Uses IPA format for apps (via App Store).
📌 Example: iOS AirDrop for file sharing.
3️⃣ Windows Mobile (Microsoft)
✔️ Discontinued (replaced by Surface Duo with Android).
✔️ Used Metro UI, similar to Windows 8.
📌 Example: Nokia Lumia series.
📌 8. Comparative Study of Mobile Operating Systems
Feature Palm OS Android Symbian OS BlackBerry iOS
OS
Developer Palm, Inc. Google Nokia BlackBerry Apple
Ltd.
Kernel Proprietary Linux-based Symbian Java-based Unix-based
Kernel
App Store No Google Play Nokia Store BlackBerry Apple App
Store World Store
Security Low Medium Medium High Very High
Market Discontinue Largest Discontinue Discontinue 2nd Largest
Share d d d
📌 Key Points:
✔️ Android dominates with open-source flexibility.
✔️ iOS leads in security & premium experience.
✔️ Symbian, BlackBerry, Palm OS are obsolete.
📌 Quick Revision Table for Exams
Topic Key Points
Mobile OS Features Touch interface, power management,
multitasking
Constraints Battery life, limited memory, security
threats
ARM vs. Intel ARM: Low power (smartphones), Intel: High
performance (laptops)
Commercial OS Android (Google), iOS (Apple), Windows
Mobile (discontinued)
Comparative Study Android (open-source), iOS (secure),
Symbian, BlackBerry (discontinued)