UNIT 1
1.1 Introduction to Operating System & Services
An Operating System (OS) is system software that acts as an interface between the
user and computer hardware. It manages hardware resources and provides a
platform for application programs. The main services provided by OS include
process management, memory management, file management, device
management, security, and user interface services.
1.2 Process, Process States, PCB, User Interface & System Calls
A process is a program in execution. Process states include New, Ready, Running,
Waiting, and Terminated. The Process Control Block (PCB) stores process
information like process ID, state, and registers. A User Interface allows interaction
with the system, while System Calls provide a mechanism for programs to request
OS services.
1.3 Linux Operating System, Architecture & File System
Linux is an open-source, multiuser, and multitasking operating system. Features of
Linux include security, portability, stability, and flexibility. Its architecture consists
of kernel, shell, system libraries, and hardware. The Linux file system organizes
data in a hierarchic
Unit 2
2.1 File Concept, Attributes, Operations, Types & Structure
A file is a collection of related data stored on secondary storage. File attributes
include name, size, type, location, protection, and timestamps. File operations are
create, read, write, delete, open, and close. File types include text, binary,
executable, and multimedia files. File structure may be none, simple records, or
complex structures.
2.2 Access Methods
The Sequential Access Method accesses data in order, one record after another.
The Direct Access Method allows accessing data directly using a file pointer or
address.
Other access methods include Indexed access and Hashed access, which improve
search speed.
2.3 Directory Structures
A directory organizes files for easy access.
Single-level directory has one directory for all users.
Two-level directory separates user directories.
Tree structure directory supports hierarchy and subdirectories.
Acyclic and General graph directories allow file sharing with links.
2.4 File System Structure & Implementation
The file system structure defines how files are stored and accessed.
Partitions divide the disk into logical sections.
Mounting connects a file system to a directory.
A Virtual File System (VFS) provides a uniform interface to different file systems.
2.5 Allocation Methods
Contiguous allocation stores files in consecutive blocks.
Linked allocation stores file blocks linked together.
Indexed allocation uses an index block to store addresses of file blocks.
Each method differs in speed, space usage, and flexibility.
2.6 Free Space Management
Free space management tracks unused disk space.
Bit vector uses bits to represent free and used blocks.
Linked list links all free blocks.
Grouping and counting improve linked list efficiency.
Space maps provide a detailed layout of free space.
Unit 3
3.1 Process Scheduling
Process scheduling decides which process gets the CPU.
Scheduling queues include ready queue, waiting queue, and device queues.
Schedulers are long-term, short-term, and medium-term schedulers.
A context switch occurs when CPU switches from one process to another.
Example: CPU switches from Process P1 to P2 when P1 waits for I/O.
3.2 Operations on Process
Process Creation (fork)
A process creates another process using fork(). The child process is a copy of the
parent.
#include <unistd.h>
int main() {
fork();
printf("Hello\n");
Example: Both parent and child print “Hello”.
Process Termination
A process terminates using exit() or after completing execution.
Example: A program ends after displaying output.
3.3 Interprocess Communication (IPC)
IPC allows processes to communicate and share data.
Shared memory allows multiple processes to access a common memory area.
Message passing sends data using send and receive operations.
Example: Producer writes data in shared memory and consumer reads it.
3.4 Multithreaded Programming
Multithreading allows multiple threads within a single process.
Threads share memory and resources.
Models include Many-to-One, One-to-One, and Many-to-Many.
Example: A web browser using multiple tabs as separate threads.
3.5 Basic Concepts
The CPU–I/O burst cycle alternates between CPU execution and I/O wait.
A CPU scheduler selects a process from the ready queue.
Pre-emptive scheduling allows OS to interrupt a running process.
A dispatcher gives control of CPU to the selected process.
Example: Time-sharing systems like Linux.
3.6 Scheduling Criteria
Scheduling criteria evaluate performance of scheduling algorithms.
They include CPU utilization, throughput, turnaround time, waiting time, and
response time.
Good scheduling maximizes CPU usage and minimizes waiting.
Example: Round Robin improves response time for interactive users.
3.7 Scheduling Algorithms (with examples)
FCFS (First Come First Serve)
Processes are executed in arrival order.
Example: P1 → P2 → P3.
SJF (Shortest Job First)
Process with smallest CPU burst executes first.
Example: Job with 2ms runs before 10ms job.
Priority Scheduling
Process with highest priority executes first.
Example: System process runs before user process.
Round Robin
Each process gets a fixed time quantum.
Example: P1, P2, P3 execute in rotation.
Multilevel Queue Scheduling
Processes are grouped into different queues.
Example: Foreground and background queues.
Multilevel Feedback Queue Scheduling
Processes can move between queues based on behavior.
Example: CPU-bound process moved to lower priority queue.
Unit 4
4.1 System Model
The system model describes how processes, resources, and the operating system
interact.
Resources such as CPU, memory, and I/O devices are allocated to processes.
Processes request, use, and release resources.
Example: A process requests CPU and printer to complete execution.
4.2 Deadlock Characterization
Deadlock occurs when processes wait indefinitely for resources.
Necessary conditions:
1. Mutual exclusion
2. Hold and wait
3. No preemption
4. Circular wait
A Resource Allocation Graph (RAG) represents processes and resources with
directed edges.
Example: P1 holds R1 and waits for R2, while P2 holds R2 and waits for R1.
4.3 Deadlock Prevention
Deadlock prevention ensures at least one necessary condition never occurs.
It may eliminate hold-and-wait, allow preemption, or enforce resource ordering.
This method is safe but may reduce system performance.
Example: Requiring a process to request all resources at once.
4.4 Deadlock Avoidance
Deadlock avoidance ensures the system always remains in a safe state.
A safe state means there exists a sequence where all processes can complete.
The Resource Allocation Graph algorithm is used for single-instance resources.
The Banker’s Algorithm is used for multiple-instance resources.
Example: Checking resource availability before granting a request.
4.5 Deadlock Detection
Deadlock detection allows deadlocks to occur and then detects them.
The system periodically checks for circular waits using graphs or matrices.
It is useful when deadlocks are rare.
Example: OS detects a cycle in the resource allocation graph.
4.6 Recovery from Deadlock
Recovery methods break the deadlock after detection.
Process termination kills one or more processes involved in deadlock.
Resource preemption temporarily takes resources from a process.
Example: Stopping a low-priority process to free resources.
Unit 5
5.1 Introduction – Memory Management Concepts
Memory management is required to efficiently allocate and utilize main memory.
Logical address space is generated by the CPU, while physical address space
refers to actual memory locations.
Static loading loads the entire program into memory at once, whereas dynamic
loading loads modules when needed.
Static linking combines all libraries at compile time.
Dynamic linking links libraries during execution, saving memory space.
5.2 Memory Management Techniques
Contiguous memory management allocates a single continuous block of memory
to a process.
It is simple but causes fragmentation.
Non-contiguous memory management allows a process to be stored in different
memory locations.
Techniques like paging and segmentation use this method.
It improves memory utilization and reduces fragmentation.
5.3 Swapping
Swapping is a technique where a process is temporarily moved from main memory
to secondary storage.
It frees main memory for other processes.
Swapping allows better CPU utilization.
It supports multiprogramming.
However, excessive swapping reduces performance.
5.4 Memory Allocation – Low Memory & High Memory
Low memory contains the operating system and kernel space.
It is always resident in memory.
High memory is allocated to user processes.
Efficient allocation ensures better performance.
Memory is divided to manage system and user requirements.
5.5 Partition Allocation Techniques
First Fit allocates the first available block.
Best Fit allocates the smallest suitable block.
Worst Fit allocates the largest available block.
Next Fit continues searching from last allocation point.
Each method differs in speed and fragmentation.
5.6 Paging
Paging divides memory into fixed-size pages and frames.
Pages are mapped to frames using a page table.
It eliminates external fragmentation.
Paging allows non-contiguous allocation.
It improves memory utilization and flexibility.
5.7 Fragmentation
External fragmentation occurs when free memory is scattered.
Internal fragmentation occurs when allocated memory is partially unused.
External fragmentation occurs in contiguous allocation.
Internal fragmentation occurs in paging.
Fragmentation reduces memory efficiency.
5.8 Segmentation
Segmentation divides memory into logical segments like code, data, and stack.
Each segment has a base and limit.
Simple segmentation uses only segmentation.
Virtual memory segmentation supports large programs.
It improves logical organization of memory.
5.9 Dynamic Loading & Dynamic Linking
Dynamic loading loads program modules into memory only when required.
It reduces memory usage.
Dynamic linking links shared libraries during execution.
It saves disk space and memory.
It allows library updates without recompiling programs.