Operating System
UNIT-I: Introduction and Memory Management
Introduction: What is an Operating System, Simple Batch Systems, Multi-programmed Batch Systems, Time-Sharing Systems, Personal-Computer Systems, Parallel Systems, Distributed Systems, Real-Time Systems. Memory Management: Background, Logical versus Physical Address Space, Swapping, Contiguous Allocation, Paging, Segmentation. Virtual Memory: Demand Paging, Page Replacement, Page-Replacement Algorithms, Performance of Demand Paging, Allocation of Frames, Thrashing, Other Considerations.
UNIT-II: Processes and CPU Scheduling
Processes: Process Concept, Process Scheduling, Operations on Processes. CPU Scheduling: Basic Concepts, Scheduling Criteria, Scheduling Algorithms, Multiple-Processor Scheduling. Process Synchronization: Background, The Critical-Section Problem, Synchronization Hardware, Semaphores, Classical Problems of Synchronization.
UNIT-III: Deadlocks
Deadlocks: System Model, Deadlock Characterization, Methods for Handling Deadlocks, Deadlock Prevention, Deadlock Avoidance, Deadlock Detection, Recovery from Deadlock.
UNIT-IV: Device Management
Device Management: Techniques for Device Management, Dedicated Devices, Shared Devices, Virtual Devices; Input or Output Devices, Storage Devices, Buffering. Secondary Storage Structure: Disk Structure, Disk Scheduling, Disk Management, Swap-Space Management, Disk Reliability.
UNIT-V: Information Management
Information Management: Introduction, A Simple File System, General Model of a File System, Symbolic File System, Basic File System, Access Control Verification, Logical File System, Physical File System. File-System Interface: File Concept, Access Methods, Directory Structure, Protection, Consistency Semantics. File-System Implementation: File-System Structure, Allocation Methods, Free-Space Management.

UNIT-I: Introduction to Operating Systems & Memory Management

1. Introduction to Operating Systems

An Operating System (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. It acts as an intermediary between users and the hardware.

Example:
When you open a browser, the OS allocates memory, schedules CPU time, and manages disk and network access.
        

2. Types of Operating Systems

3. Memory Management

Memory Management is a core function of the OS that handles how memory is allocated and accessed.

4. Virtual Memory

Virtual memory allows programs to use more memory than physically available by using disk as an extension.

4.1 Demand Paging

Pages are brought into memory only when needed (on-demand).

Example:
Page 4 not in memory → Page fault → OS loads Page 4 from disk.
        

4.2 Page Replacement

Replaces existing pages when memory is full.

Example:
Pages in RAM = [2, 3, 1]
Request = Page 4 → Replace LRU (Page 2) → RAM = [4, 3, 1]
        

4.3 Performance of Demand Paging

Depends on how often page faults occur. Fewer page faults = better performance.

4.4 Allocation of Frames

Frames are given to processes using strategies like equal, proportional, global/local allocation.

4.5 Thrashing

Occurs when the system spends more time swapping pages than executing actual processes.

Example:
Too many processes → Constant swapping → CPU idle.
        

4.6 Other Considerations

Includes optimizations like prepaging and TLBs for faster address translation.

UNIT-II: Processes, Scheduling & Synchronization

1. Process Concept

A process is a program in execution. It includes the program code, current activity, and process resources like registers, memory, and open files.

Example:
Opening MS Word creates a process with its own memory, CPU registers, and files.
        

2. Process Scheduling

Determines the order in which processes access the CPU.

3. Process Synchronization

Ensures processes don’t interfere with each other while accessing shared data.

UNIT-III: Deadlocks

1. System Model

A system consists of a finite number of resources to be distributed among competing processes. Resources may be preemptible or non-preemptible.

Example:
Resources: R1 (Printer), R2 (Scanner)
Processes: P1 and P2 both need R1 and R2 to finish.
        

2. Deadlock Characterization

Deadlock occurs when a group of processes are each waiting for resources held by others in the group, leading to a cycle of dependency.

Example:
P1 holds R1 and waits for R2.
P2 holds R2 and waits for R1 → Deadlock.
        

3. Methods for Handling Deadlocks

There are three general approaches:

4. Deadlock Prevention

Ensure that at least one of the necessary conditions for deadlock does not hold.

Example:
Request all resources together: request(R1, R2) instead of R1 first, then R2.
        

5. Deadlock Avoidance

Use information about future resource requests to ensure the system never enters a deadlock state.

Banker's Algorithm: Allocates resources only if it leaves the system in a safe state.

Example:
If P1 needs 2 more units, but only 1 is available → Delay allocation to P1.
        

6. Deadlock Detection

Allow deadlock to occur and then detect it using a resource allocation graph or wait-for graph.

Example:
Cycle in wait-for graph → Deadlock is present.
        

7. Recovery from Deadlock

Once detected, system must recover using one of the following methods:

Example:
Terminate P2 to release R2 → Allow P1 to continue.
        

UNIT-IV: Device Management & Secondary Storage Structure

1. Techniques for Device Management

Device Management controls all hardware devices and manages their input/output operations. The OS communicates with devices via device drivers.

Example:
The printer driver converts data from applications into a format that the printer understands.
        

2. Types of Devices

3. Input and Output Devices

Input devices send data to the computer (e.g., keyboard, mouse), while output devices receive data from the computer (e.g., monitor, printer).

Example:
Mouse → Input Device
Display Monitor → Output Device
        

4. Storage Devices

Devices used to store data, including primary (RAM), secondary (Hard Drive), and tertiary (optical discs, backup tapes).

Example:
HDD, SSD, USB drives, DVDs
        

5. Buffering

Buffering is the process of storing data temporarily in memory while transferring between devices and applications.

Example:
While streaming a video, the buffer holds a few seconds of video to ensure smooth playback.
        

6. Secondary Storage Structure

6.1 Disk Structure

Disk drives are organized into platters, tracks, and sectors. Data is stored in sectors along tracks on rotating platters.

Example:
Track 0, Sector 1 might store part of a file.
        

6.2 Disk Scheduling

Disk scheduling optimizes the order of read/write requests to reduce seek time.

Example:
Requests: 10, 22, 20, 2, 40
SSTF: 20 → 22 → 10 → 2 → 40 (shortest distance first)
        

6.3 Disk Management

Includes partitioning, formatting, and mounting file systems on the disk.

Example:
Formatting a drive prepares it to store files by creating a file system.
        

6.4 Swap-Space Management

Swap space is used to extend RAM by moving inactive pages from RAM to disk.

Example:
If RAM is full, OS swaps out Process A’s memory to disk to load Process B.
        

6.5 Disk Reliability

Techniques to ensure data is not lost or corrupted.

Example:
RAID 1 mirrors data to two disks to protect against failure.
        

UNIT-V: Information Management & File System

1. Introduction

Information Management in operating systems involves organizing and controlling access to data stored in files on storage devices.

2. A Simple File System

A simple file system provides basic functions like file creation, deletion, reading, writing, and naming.

Example:
Creating a text file with .txt extension using a text editor and saving it to disk.
        

3. General Model of a File System

A file system has several layers: application, logical file system, file-organization module, and basic file system.

Example:
User → Application → LFS → File Organization → Disk Operations
        

4. Symbolic & Basic File Systems

The symbolic file system translates file names to file identifiers. The basic file system handles actual read/write requests to blocks.

Example:
Symbolic: "report.doc" → inode 123
Basic: inode 123 → block 15 → fetch data
        

5. Access Control Verification

This ensures only authorized users can access or modify specific files using permissions like read, write, and execute.

Example:
chmod 755 file.txt → Owner: rwx, Group: r-x, Others: r-x
        

6. Logical & Physical File Systems

Example:
User requests file.txt → Logical FS locates it → Physical FS reads it from disk
        

7. File System Interface

7.1 File Concept

Files are logical storage units that store related information, such as documents, images, or programs.

7.2 Access Methods

Example:
MP3 player reading songs sequentially → Sequential access
        

7.3 Directory Structure

Organizes files in a hierarchical tree-like structure for easy access and management.

Example:
C:/Users/Student/Documents/Notes.txt
        

7.4 Protection

Prevents unauthorized access or modifications to files.

Example:
Read-only files can't be edited without permission.
        

7.5 Consistency Semantics

Defines how changes to files are visible to users, especially in multi-user environments.

Example:
UNIX semantics: updates are immediately visible to other users.
        

8. File System Implementation

8.1 File System Structure

Includes boot control block, volume control block, directory structure, and file control blocks (FCB).

8.2 Allocation Methods

Example:
File = 3 blocks → Contiguous: 5,6,7 | Linked: 5→6→7 | Indexed: [5,6,7]
        

8.3 Free-Space Management

Tracks unallocated disk space using bitmaps, free lists, or grouping.

Example:
Bitmap: 0010110 → 0 = Free, 1 = Used