UNIT I – INTRODUCTION (DETAILED NOTES)
1. Operating System Definition
An Operating System (OS) is system software that manages hardware and software resources,
providing services to both programs and users. It simplifies hardware complexity by offering
a user-friendly interface and ensures efficient execution of applications.
2. Functions of Operating System
a) Process Management:
Handles creation, scheduling, execution and termination of processes. Maintains process states
and ensures smooth multitasking. Includes context switching, process synchronization, and
inter-process communication.
b) Memory Management:
Manages allocation and deallocation of memory to processes. Keeps track of free/used memory.
Provides protection by ensuring processes do not access memory of others.
c) File Management:
Responsible for storing, retrieving, naming, deleting and organizing files. Provides structure
using directories and permissions for secure access.
d) Device Management:
Manages I/O devices via drivers. Allocates devices, handles interrupts, ensures no devices
conflict during use.
e) Protection and Security:
Prevents unauthorized access using authentication, authorization, access control lists and
permissions.
f) Resource Allocation:
Distributes CPU time, memory space, I/O devices and storage among processes efficiently.
g) Error Detection:
Detects CPU, memory, I/O and software errors. Helps OS recover using predefined strategies.
3. Types of Operating Systems
a) Batch OS:
Jobs are collected, grouped and executed in batches without user interaction. Useful for long,
repetitive tasks.
b) Time-Sharing OS:
Multiple users share CPU simultaneously. Uses time quantum for switching. Ensures quick
response time.
c) Distributed OS:
Multiple computers act as a single system. Enables resource sharing across locations.
d) Real-Time OS:
Delivers output within strict timing constraints.
• Hard Real-Time: No delay allowed (nuclear systems, avionics)
• Soft Real-Time: Occasional delays acceptable (gaming, multimedia)
4. System Protection
Prevents interference between processes using:
• Access control
• User authentication
• Privilege levels
• File permissions
• Memory protection boundaries
5. System Components
Major OS components include:
• Process Manager
• Memory Manager
• File System
• I/O System
• Storage Manager
• Security Module
• Shell/Command Interpreter
6. System Structure
a) Simple/Monolithic:
All services in one large program. Fast but difficult to debug.
b) Layered Architecture:
OS is divided into layers where each layer only interacts with the layer below.
c) Microkernel:
Only essential services run in kernel mode; others run in user mode. Offers modularity and
security.
7. OS Services
• Program execution
• Input/output operations
• File manipulation
• Communication using pipes, shared memory, sockets
• Error detection
• Resource allocation
• Logging and accounting
UNIT II – CONCURRENT PROCESS (DETAILED NOTES)
1. Concept of Process
A process is an active program with states, memory, registers, stack, data and code segment.
Processes may execute concurrently, sharing CPU time.
2. Process States
a) New
b) Ready
c) Running
d) Waiting/Blocked
e) Terminated
State transitions occur during CPU scheduling, I/O activities or completion of tasks.
3. Interrupts
Interrupts allow CPU to respond to urgent events:
• Hardware Interrupts (generated by devices)
• Software Interrupts (system calls, exceptions)
4. Process Control Block (PCB)
PCB stores entire context of a process:
• Process ID
• Program counter
• CPU registers
• Memory limits
• Scheduling information
• Open files list
It allows processes to resume correctly after interruption.
5. Concurrency
Concurrency refers to multiple processes executing within overlapping time frames. Essential
for improved CPU utilization and faster system response.
Issues in concurrency:
• Race conditions
• Deadlocks
• Starvation
• Data inconsistency
6. Producer–Consumer Problem
Producer adds items to buffer, consumer removes them. Requires synchronization using:
• Semaphores
• Mutex locks
• Condition variables
7. Critical Section Problem
Critical section contains code accessing shared variables. Must satisfy:
• Mutual exclusion
• Progress
• Bounded waiting
Solutions:
• Peterson’s algorithm
• Semaphores
• Mutex locks
UNIT III – CPU SCHEDULING & DEADLOCK (DETAILED NOTES)
1. Scheduling Concepts
CPU scheduling improves CPU utilization and throughput. It selects a process from ready queue
to execute next.
Criteria:
• CPU utilization
• Throughput
• Turnaround time
• Waiting time
• Response time
2. Scheduling Algorithms
a) FCFS:
Processes served in order of arrival. Non-preemptive. Simple but causes convoy effect.
b) SJF:
Process with shortest burst time executed first. Optimal for waiting time but requires burst
time prediction.
c) Round Robin:
Each process gets fixed time slice. Ensures fairness in time-sharing systems.
d) Priority Scheduling:
Highest priority process executed first. May cause starvation.
e) Multilevel Queue:
Separate queues for different process types.
3. Deadlock
Deadlock occurs when processes are stuck waiting for resources held by each other.
Conditions (Coffman Conditions):
• Mutual exclusion
• Hold and wait
• No preemption
• Circular wait
4. Deadlock Handling
a) Prevention:
Break at least one deadlock condition.
b) Avoidance:
Use resource allocation graphs, Banker’s algorithm.
c) Detection:
Check for cycles.
d) Recovery:
Terminate process or preempt resources.
UNIT IV – MEMORY MANAGEMENT (DETAILED NOTES)
1. Memory Management Overview
Manages primary memory and ensures efficient allocation to processes.
2. Resident Monitor
Small portion of OS always in memory, tracks jobs and manages CPU.
3. Multiprogramming
Multiple programs reside in memory. Two types:
a) Fixed Partitioning
b) Variable Partitioning
4. Fragmentation
External: unused memory between partitions.
Internal: unused memory inside allocated partition.
5. Segmentation
Logical memory divided into segments: code, data, stack.
6. Paging
Memory divided into fixed-sized pages. Eliminates external fragmentation.
7. Virtual Memory
Allows execution of processes larger than RAM using secondary storage.
Main methods:
• Demand paging
• Page table
• TLB (Translation Lookaside Buffer)
8. Page Replacement Algorithms
a) FIFO
b) Optimal
c) LRU
d) LFU
e) Clock Algorithm
9. Thrashing
Occurs when OS spends more time swapping pages than executing processes.
10. Cache Memory
High-speed memory with:
• Direct mapping
• Associative mapping
• Set-associative mapping
UNIT V – UNIX/LINUX (DETAILED NOTES)
1. Unix Architecture
• Hardware
• Kernel
• Shell
• Utilities
• Applications
2. Kernel Responsibilities
• File system management
• Process management
• Device management
• Memory management
• System calls
3. Files & Directories
Unix treats everything as a file.
Directory types:
• Root (/)
• Home directories
• System directories (/bin, /usr, /etc)
4. Basic Commands
ls, pwd, cd, mkdir, rmdir, cat, cp, mv, rm, chmod, chown, ps, kill, man.
5. Shell Types
• Bourne Shell (sh)
• Bash
• Korn Shell (ksh)
• C Shell (csh)
6. Shell Variables
• Local variables
• Environment variables
7. Shell Scripting
Includes:
• Conditional statements (if, else, elif)
• Loops (for, while, until)
• Arithmetic operations
• String operations
• Functions
8. Decision Making in Shell
Shell supports:
• if-else
• case statements
• logical operators