Introduction to Operating Systems
An Operating System (OS) is system software that manages computer hardware and provides an
environment for applications to run. It acts as an intermediary between the user and the hardware. The
OS ensures efficient resource utilization, controls system activities, and provides essential services to
users and applications.
Functions of Operating Systems
1. Process Management
o Creates, schedules, and terminates processes
o Handles multitasking and inter-process communication (IPC)
2. Memory Management
o Allocates and deallocates memory to programs
o Manages virtual memory and paging
3. File System Management
o Manages file creation, deletion, reading, writing
o Organizes files in directories and controls access
4. Device (I/O) Management
o Controls hardware devices through drivers
o Handles buffering, spooling, and device communication
5. Security and Protection
o Provides user authentication, permissions, and access control
o Protects system resources from unauthorized access
6. User Interface Management
o Provides GUI or CLI for user interaction
7. Networking
o Supports communication between computers
o Manages network protocols and sharing
Operating System Design Approaches
1. Layered Approach
The OS is divided into layers, each built on top of the other.
Lower layers interact with hardware, while higher layers provide user services.
Features
Modular design
Easy debugging and maintenance
Strict control of information flow
Examples
The THE system
Some UNIX implementations
2. Kernel-Based Approach
a) Monolithic Kernel
Entire OS runs in kernel mode.
All services (file system, drivers, scheduling) are part of one large kernel.
Advantages: Fast, efficient
Disadvantages: Hard to maintain, less secure
Examples: Linux, traditional UNIX
b) Microkernel
Only essential functions (IPC, memory, CPU scheduling) in the kernel.
Other services run in user mode.
Advantages: Reliable, secure, modular
Disadvantages: Slower due to message passing
Examples: Minix, QNX
c) Hybrid Kernel
Combines monolithic speed and microkernel modularity.
Examples: Windows, macOS
3. Virtual Machine Approach
The OS provides a Virtual Machine (VM) interface that mimics real hardware.
Allows multiple OS instances to run on the same hardware using a hypervisor.
Features
Strong isolation between systems
Excellent for testing, virtualization, and server consolidation
Provides security and resource control
Examples
VMware, VirtualBox
Hypervisor-based virtualization (e.g., Hyper-V)
Types of Advanced Operating Systems
1. Network Operating System (NOS)
Supports networking, file sharing, remote login, and communication between multiple
computers.
Examples:
Windows Server, Linux Server, Novell NetWare
2. Multiprocessor Operating System
Designed to run on systems with multiple CPUs working in parallel.
Supports symmetric multiprocessing (SMP) and parallel processing.
Features:
High performance
Load balancing
Increased reliability
Examples:
Windows Server (SMP support), Linux multiprocessor kernels
3. Mobile Operating System
Designed for smartphones and tablets.
Optimized for touch input, low power consumption, and wireless communication.
Examples:
Android, iOS, HarmonyOS
4. Real-Time Operating System (RTOS)
Provides immediate, deterministic response to events.
Used in time-critical applications.
Types:
Hard RTOS (strict deadlines)
Soft RTOS (flexible deadlines)
Examples:
Free RTOS, VxWorks, QNX
5. Cloud Operating System
Manages cloud infrastructure and provides virtualized services over the internet.
Supports distributed computing, multi-tenancy, and resource scaling.
Examples:
OpenStack, Google’s Chrome OS, Microsoft Azure OS (fabric controllers)
1. PROCESS CONCEPT
A process is a program in execution. It is an active entity, unlike a program (which is passive, just a
file on disk).
A process includes:
Program code (text section)
Current activity (program counter, registers)
Process stack (function parameters, local variables, return addresses)
Data section (global variables)
Heap (memory allocated during runtime)
Process States:
A process typically moves through these states:
1. New – process is being created
2. Ready – ready and waiting to be assigned to a CPU
3. Running – instructions are being executed
4. Waiting/Blocked – waiting for I/O or some event
5. Terminated – finished execution
Process vs Program
Program Process
Passive file containing instructions Active entity executing the program
Stored on disk Exists in memory & CPU
No lifecycle Has a complete lifecycle
2. PROCESS CONTROL BLOCK (PCB)
A Process Control Block (PCB) is a data structure maintained by the operating system to store all
information about a process.
It acts like the "identity card" or "brain" of a process.
Contents of a PCB:
1. Process ID (PID)
2. Process State (Ready, Running, Blocked…)
3. Program Counter – next instruction to execute
4. CPU Registers – saved when switching the process
5. Memory Management Info
o base and limit registers
o page tables
o segment tables
6. Scheduling Information
o priority
o scheduling queue pointers
7. Accounting Information
o CPU usage
o execution time
8. I/O Status Information
o allocated devices
o open files list
Role of PCB in Context Switching
During context switching, the OS:
Saves the state (registers, PC…) of the running process into its PCB
Loads another process's state from its PCB into the CPU
This allows multitasking.
3. PROCESS SCHEDULING
Process Scheduling is the OS activity that decides which process runs on the CPU next.
The component responsible is called the CPU Scheduler.
Objectives of Scheduling
Maximize CPU utilization
Maximize throughput
Minimize waiting time
Minimize response time
Provide fairness
Types of Schedulers
1. Long-Term Scheduler (Job Scheduler)
o Decides which jobs enter the ready queue
o Controls degree of multiprogramming
2. Short-Term Scheduler (CPU Scheduler)
o Selects which ready process runs next
o Runs frequently
3. Medium-Term Scheduler
o Performs swapping (suspending/resuming processes)
o Helps manage memory
Scheduling Algorithms
Some commonly used scheduling algorithms:
Algorithm Key Idea
FCFS (First Come First Serve) Non-preemptive; jobs run in arrival order
SJF (Shortest Job First) Picks process with smallest CPU burst
Priority Scheduling Highest priority runs first
Round Robin (RR) Time slices (quantum); fair for all
Multilevel Queue Separate queues for different classes of processes
Multilevel Feedback Queue Processes move between queues based on behavior
PROCESS MANAGEMENT
1. Process Concept
A process is a program in execution.
It includes: program code, data, stack, registers, program counter, and resources (files, memory).
2. Process Control Block (PCB)
PCB is a data structure used by the OS to store information about a process.
It contains:
Process ID
Process state
Program counter
CPU registers
Scheduling information
Memory management info
I/O status
Accounting information
3. Process Scheduling
Process scheduling selects which ready process will run next.
Goal: maximize CPU utilization and throughput, minimize waiting time and response time.
CPU SCHEDULING
1. Scheduling Concept
CPU scheduling decides the order in which processes will use the CPU.
2. Scheduling Criteria
CPU utilization
Throughput
Turnaround time
Waiting time
Response time
Fairness
3. Scheduling Algorithms
1. FCFS (First Come First Serve)
2. SJF (Shortest Job First)
3. SRTF (Shortest Remaining Time First)
4. Priority Scheduling
5. Round Robin (Time quantum based)
6. Multilevel Queue / Multilevel Feedback Queue
PROCESS SYNCHRONIZATION & DEADLOCK
1. Synchronization Concept
Synchronization ensures that multiple processes can access shared resources without conflict and
maintain data consistency.
2. Synchronization Requirement
Mutual exclusion
Progress
Bounded waiting
Required to solve race conditions.
3. Critical Section Problem
Part of a program where shared resources are accessed.
Solution must satisfy:
Mutual exclusion
Progress
Bounded waiting
4. Monitors
A high-level synchronization construct that uses:
Variables
Condition variables
Procedures
Only one process can be active inside a monitor at one time.
DEADLOCK
1. Deadlock Concept
Deadlock occurs when a set of processes are blocked forever, waiting for resources held by one
another. 4 Necessary Conditions
(Coffman’s conditions)
a. Mutual Exclusion
b. Hold and Wait
c. No Preemption
d. Circular Wait
2. Deadlock Prevention
Prevent at least one of the 4 conditions:
Avoid mutual exclusion (not always possible)
No hold and wait
Allow preemption
Break circular wait (resource ordering)
3. Deadlock Avoidance
Ensure deadlock will never occur by checking safe state.
Example: Banker’s Algorithm.
4. Deadlock Detection
Allows deadlock to occur, then OS detects it using:
Wait-for graph
Resource allocation graph
5. Deadlock Recovery
After detection, OS recovers using:
Process termination
Resource preemption
Memory management is a critical aspect of operating systems that
ensures efficient use of the computer's memory resources. It controls how memory is allocated and
deallocated to processes, which is key to both performance and stability. Below is a detailed
overview of
the various components and techniques involved in memory management.
Memory Management
Why Memory Management is Required?
Allocate and de-allocate memory before and after process execution.
To keep track of used memory space by processes.
To minimize fragmentation issues.
To proper utilization of main memory.
To maintain data integrity while executing of process.
Logical and Physical Address Space
Logical Address Space: The logical address space is the set of all addresses that a process can
generate using its CPU. It defines
the range of memory locations available to the process from its perspective.
Physical Address Space: The physical address space is the set of all actual memory addresses
in the main memory (RAM). It
represents the real locations where data and instructions are stored.
Static and Dynamic Loading
Loading a process into the main memory is done by a loader. There are two different types of
loading :
Static Loading: Static Loading is basically loading the entire
program into a fixed address. It requires more memory space.
Dynamic Loading: Dynamic loading loads program routines into memory only when they are
needed. This saves memory by not loading unused routines. The routines remain on disk in
relocatable(can be loaded at any memory location) format until called. It allows better
memory utilization, especially for large
programs.
Static and Dynamic Linking
A linker combines object files into a single executable.
Static Linking: All required modules are combined into one executable. No runtime
dependency; some OSes support only this method.
Dynamic Linking: Uses a stub (small code) for library calls. At runtime, the stub checks if
the routine is in memory; if not, it loads it.
Swapping
Swapping moves processes between main memory and secondary memory to manage limited
memory space. It allows multiple
processes to run by temporarily swapping out lower priority
processes for higher priority ones. The swapped-out process resumes once it's loaded back. Transfer
time depends on the amount of data swapped.
Memory Management Techniques
Memory management techniques are methods used by an operating system to efficiently allocate,
utilize, and manage memory resources for processes. Various techniques help the operating system
manage memory effectively. They can be broadly categorized into:
Memory Management with Monoprogramming (Without Swapping)
This is the simplest memory management approach the memory is divided into two sections: One
part of the operating system. The
second part of the user program
The OS is loaded either at the bottom or the top of memory.
Since interrupt vectors are usually placed in low memory, the OS is often loaded there.
In a single-process system, sharing code or data is unnecessary.
The OS is protected from user programs using a fence register.
Multiprogramming with Fixed Partitions (Without Swapping)
A memory partition scheme with a fixed number of partitions was introduced to support
multiprogramming. this scheme is based on contiguous allocation
Each partition is a block of contiguous memory
Memory is partitioned into a fixed number of partitions.
Each partition is of fixed size
Partition Table : Once partitions are defined operating system keeps track of the status of memory
partitions it is done through a data structure called a partition table.
Starting Address of Partition Size of Partition Status
0k 200k allocated
200k 100k free
300k 150k free
450k 250k allocated
Contiguous Memory Allocation
Contiguous memory allocation is a memory management method where each process is given a
single, continuous block of memory. This means all the data for a process is stored in adjacent
memory locations.
Non-Contiguous Memory Allocation
This method allows processes to be broken into smaller parts, which are placed in different, non-
adjacent memory locations. Techniques for non-contiguous memory allocation include:
Paging: The process is divided into fixed-size blocks called
"pages," and the memory is divided into blocks of the same size called "frames." The
operating system keeps a page table to map logical pages to physical frames.
Segmentation: The process is divided into segments of varying sizes, such as code, data,
stack, etc. The operating system maintains a segment table to map logical segments to
physical memory.
Fragmentation
Fragmentation occurs when processes are loaded and removed from memory, leaving small unusable
gaps. These gaps cannot be allocated to new processes because they are either too small or
scattered.
Types of Fragmentation:
Internal Fragmentation: Wasted space inside allocated memory blocks when a process is given
more memory than it needs.
External Fragmentation: Free memory exists but is divided into small scattered blocks,
preventing allocation of large contiguous space.
Memory Allocation Strategies
Efficient memory allocation is essential for optimal performance. There are several strategies for
allocating memory blocks:
1. Fixed Partition Allocation: Memory is divided into fixed-sized partitions, and each partition
can hold only one process. The OS keeps track of free and occupied partitions using a partition
table.
2. Dynamic Partition Allocation: Memory is divided into variable-
sized partitions based on the size of the processes. This helps avoid wastage of memory but can result
in fragmentation.
3. Placement Algorithms: When allocating memory, the OS uses
placement algorithms to decide which free block should be assigned to a process:
First Fit: Allocates the first available partition large enough to hold the process.
Best Fit: Allocates the smallest available partition that fits the process, reducing wasted
space.
Worst Fit: Allocates the largest available partition, leaving the largest remaining space.
Next Fit: Similar to First Fit but starts searching for free memory from the point of the last
allocation.
4. The key concepts related to distributed operating systems listed in the image are detailed below. A
distributed operating system (DOS) manages a collection of independent computers and makes them
appear as a single, coherent system to the user.
5. Distributed Operating System Concepts Goals
6. The primary goals of a DOS include:
7. Resource Sharing: Allowing users to access hardware and software resources across the network.
8. Increased Fault Tolerance: The system can continue to operate even if some nodes fail.
9. Scalability: The ability to easily add more processors to handle increased load.
10. Transparency: Hiding the physical distribution of resources from the users.
11. Distributed Computing Models
12. These models define how processes communicate and interact across the network:
13. Message Passing: Processes communicate by sending and receiving messages.
14. Remote Procedure Calls (RPC): A process on one machine can call a procedure on another machine
as if it were a local call.
15. Distributed Shared Memory (DSM): Provides an abstraction of a shared memory space across
physically separate machines.
16. Hardware Concepts
17. Hardware concepts involve the physical interconnection of multiple processors.
18. Systems use interconnected multiple processors instead of a single, high-speed processor.
19. Hardware elements can be spread across various locations, linked by communication lines.
20. Software Concepts
21. Software concepts deal with the algorithms and mechanisms for managing the distributed
environment.
22. Synchronization: Mechanisms like clock synchronization and event ordering are crucial.
23. Mutual Exclusion: Algorithms (token-based or non-token-based)
24. ensure that only one process can access a critical resource at a time.
25. Resource Management: Approaches to global scheduling, task management, and load balancing are
used.
26. Architecture of DOS
27. A DOS architecture is built to allow for efficient, scalable, and fault- tolerant computing across
multiple machines. It provides a virtual machine abstraction to users while managing the underlying
28. distributed resources.
29. Design Issues
30. Key design issues address challenges in building an effective DOS:
31. Transparency: Hiding implementation and physical distribution details from users.
32. Flexibility: The ease with which the system can be modified or extended.
33. Scalability: The system's capacity to handle a growing amount of work or its ability to be enlarged to
accommodate growth.
34. Reliability: The system's ability to perform its required functions under stated conditions for a specified
period of time.
35. Performance: Ensuring the system operates efficiently and with minimal latency.
36. Fault Tolerance: The ability to recover from failures of individual components without affecting the
entire system.
1) Explain Paging, Segmentation, Demand Paging, Page Fault, and Page Replacement Algorithms.
1. Paging
Paging is a memory management technique in which the logical memory of a process is divided into
fixed-size blocks called pages, and physical memory is divided into blocks of the same size called frames.
Since page and frame sizes are equal, any page can be placed in any free frame.
This removes external fragmentation completely.
To map pages to frames, the OS maintains a page table.
The CPU generates logical addresses that are converted to physical addresses using the page table.
Advantages:
No external fragmentation
Efficient memory utilization
Easy to allocate and deallocate
2. Segmentation
Segmentation divides memory based on logical divisions of a program such as code, data, stack, heap,
arrays, functions, etc.
Each segment has a variable size. A segment table is used which contains the base address and length of
each segment.
Segmentation supports the programmer’s view of memory and allows user-friendly memory
organization.
Advantages:
Supports modular programming
Easy sharing and protection
Better representation of user’s logical structure
3. Demand Paging
Demand paging is a type of virtual memory management where pages are loaded into memory only
when they are required during execution.
If a page is not needed, it is not loaded.
This reduces memory usage and increases system efficiency.
How it works:
CPU tries to access a page
If page is in RAM → normal execution
If not → page fault occurs
OS loads the required page from secondary memory (disk) into RAM
4. Page Fault
A page fault occurs when the CPU tries to access a page that is not currently available in physical
memory.
Reasons for page fault:
Page is not loaded yet
Page was removed to free space
Invalid reference (rare)
Steps of handling page fault:
1. Detect page fault
2. Check if reference is valid
3. Locate page in secondary memory
4. Bring page into a free frame
5. Update page table
6. Resume the process
5. Page Replacement Algorithms
When memory is full and a new page needs to be loaded, the OS decides which page to remove using a
replacement algorithm.
a) FIFO (First In First Out):
The page that entered earliest is removed first.
Simple but may remove frequently used pages.
b) LRU (Least Recently Used):
The page that has not been used for the longest time is replaced.
Gives better performance than FIFO.
c) Optimal Algorithm:
Replaces the page that will not be used for the longest time in the future.
Gives the best results but impossible to implement practically.
Conclusion:
Paging, segmentation, and demand paging together allow efficient use of memory.
Page faults and replacement algorithms ensure that the right pages stay in memory while less important
ones are removed.
Q.2) Explain Distributed Operating Systems in detail along with goals, architecture, models, and
design issues.
1. Introduction
A Distributed Operating System (DOS) is an operating system that manages a collection of independent
computers and makes them appear as a single coherent system to the user.
The primary objective is resource sharing, improved performance, reliability, and transparency.
2. Goals of Distributed OS
1. Transparency:
Hide the fact that multiple machines are involved.
Types: access, location, migration, replication, and concurrency transparency.
2. Flexibility:
Easily add or remove nodes without affecting system behaviour.
3. Scalability:
System should support a growing number of users and devices.
4. Performance:
Faster processing through parallel execution.
5. Reliability:
System continues to work even if some components fail.
6. Fault Tolerance:
Techniques like replication ensure the system runs even after failures.
3. Distributed Computing Models
a) Client–Server Model:
Clients send requests; servers provide services.
Most web applications use this.
b) Peer-to-Peer Model:
All devices are equal and share resources directly.
Examples: File-sharing networks, blockchain.
c) Hybrid Model:
Combination of both client-server and P2P.
d) Cluster Computing:
Group of computers work like a single high-performance system.
e) Cloud Computing:
Resources like storage and processing provided over the internet.
4. Architecture of Distributed OS
a) Layered Architecture:
Application layer
Middleware layer
Operating system layer
Hardware layer
b) Client-Server Architecture:
Clients request and servers respond.
c) Object-Based Architecture:
Services represented as objects.
Used in CORBA and RMI systems.
5. Design Issues in Distributed OS
a) Transparency:
User should feel that the whole system is a single computer.
Types: access, location, migration, failure transparency.
b) Scalability:
Should handle a large number of machines and users without performance loss.
c) Performance:
Efficient communication, load balancing, and scheduling improve performance.
d) Reliability & Fault Tolerance:
Redundant copies of data ensure smooth functioning even after failures.
e) Communication:
Nodes communicate using message passing, RPC, and sockets.
f) Security:
Protection against unauthorized access, data leakage, and network attacks.
Conclusion:
Distributed Operating Systems enhance performance, scalability, and reliability.
They play a crucial role in modern environments like cloud computing, data centers, and large networks.
Q.3) Explain Mobile Operating System Architecture and compare Android, iOS, Virtual OS, and Cloud
OS.
1. Introduction
A Mobile Operating System is software that manages smartphone hardware and provides an
environment for running applications.
It handles memory, power, security, user interface, and device communication.
2. Architecture of Mobile OS
Most mobile OS have a layered architecture:
1. Application Layer:
Contains apps like dialer, browser, messaging, games.
2. Application Framework:
Provides APIs for developers.
Manages activities, windows, content providers.
3. Libraries:
Includes graphics, database (SQLite), media, security libraries.
4. Runtime Environment:
Executes application code.
Android uses ART, iOS uses Objective-C/Swift runtime.
5. Kernel Layer:
Lowest layer that interacts with hardware.
Manages memory, drivers, power, and processes.
3. Android OS
Open-source and based on Linux kernel
Developed by Google
Supports Java & Kotlin
Components:
Activities
Services
Broadcast receivers
Content providers
Multi-tasking support
Huge application ecosystem (Play Store)
4. iOS
Closed-source OS by Apple
Highly secure and stable
Architecture:
Cocoa Touch
Media Layer
Core Services
Core OS
Uses Swift and Objective-C
Smooth UI and optimized hardware-software integration
5. Virtual OS
A virtual OS is an operating system running inside virtualization software (VMware, VirtualBox).
Features:
Isolation between host and guest OS
Easy testing and development
Resource sharing (CPU, RAM, disk)