0% found this document useful (0 votes)
2 views22 pages

Operating System

The document provides an overview of operating systems, detailing their functions such as process management, memory management, and security. It discusses various types of operating systems, system calls, processes, threads, inter-process communication (IPC), and concurrency with synchronization mechanisms. Key concepts include the distinction between processes and threads, types of IPC methods, and the importance of synchronization to prevent race conditions.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views22 pages

Operating System

The document provides an overview of operating systems, detailing their functions such as process management, memory management, and security. It discusses various types of operating systems, system calls, processes, threads, inter-process communication (IPC), and concurrency with synchronization mechanisms. Key concepts include the distinction between processes and threads, types of IPC methods, and the importance of synchronization to prevent race conditions.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Lecture 1 (Introduction)

15 May 2026 15:08

• An Operating System (OS) is system software that acts as an interface between the user and computer hardware.
• It manages resources like CPU, memory, and input/output devices.

1. Process Management – Handles creation, scheduling, and termination of processes.


2. Memory Management – Allocates and deallocates memory space as needed.
3. File System Management – Organizes, stores, and retrieves data on storage devices.
4. Device Management – Controls and coordinates input/output devices.
5. Security & Protection – Ensures authorized access and safeguards data.
6. User Interface – Provides ways (CLI, GUI) for users to interact with the system .

New Section 1 Page 1


Lecture 2 (Types of OS)
15 May 2026 15:09

• Batch Operating System


• Jobs are collected and executed in batches without user interaction.
• Efficient for large volumes of repetitive tasks but lacks real-time feedback.
• Multiprogramming Operating System
• Multiple programs share CPU time.
• Increases utilization by keeping the CPU busy, but requires good memory management.
• Time-Sharing Operating System
• Allows multiple users to interact with the system simultaneously.
• CPU time is divided into small slices, giving the illusion of parallel execution.
• Multiprocessing Operating System
• Uses multiple CPUs to execute tasks concurrently.
• Improves speed and reliability, often used in high-performance systems.
• Real-Time Operating System (RTOS)
• Designed for tasks requiring immediate response (e.g., robotics, medical devices).
• Prioritizes deadlines and ensures predictable execution.

New Section 1 Page 2


System calls
23 May 2026 21:26

Great. Let’s start with System Calls. This topic is the gateway between a user program and the operating system
kernel, and it is one of the first OS concepts you should understand well.

1. What is a System Call?


A system call is a controlled request made by a user program to the operating system to get a service from the
kernel.
A normal program cannot directly access hardware or protected OS resources, so it uses system calls as the interface.
Simple Meaning
• User program needs a service.
• It asks the OS through a system call.
• The OS performs the task safely.
• Control returns to the program.

2. Why System Calls Are Needed


System calls are needed because direct access to hardware would be unsafe and unstable.
They provide a safe way for programs to do tasks like opening files, creating processes, reading input, writing output,
and communicating with other processes.

3. How System Calls Work


When a program makes a system call, the CPU switches from user mode to kernel mode so the OS can perform the
requested operation.
After the work is done, control returns to the user program.

Important Exam Point


A system call involves a mode switch, but not always a full context switch. A context switch happens only if the
process must wait or block.

4. Types of System Calls


The main categories are:
• Process control.
• File management.
• Device management.
• Information maintenance.
• Communication.

A. Process Control
These calls create, terminate, and manage processes.
Examples: fork(), exit(), wait(), exec().

B. File Management
These calls create, open, read, write, and close files.
Examples: open(), read(), write(), close().

C. Device Management
These calls manage device access and I/O control.
Example: ioctl() in Unix-like systems.

D. Information Maintenance
These calls get or set system information like time, process ID, or status.
Examples: getpid(), alarm(), sleep().

Topic Wise Notes Page 3


E. Communication
These calls help processes communicate with each other.
Examples: pipe(), shared memory, message-related calls.

5. Common Examples
• fork() creates a new process.
• exec() runs a new program inside a process.
• wait() waits for a child process to finish.
• open() opens a file.
• read() reads from a file.
• write() writes to a file.
• close() closes a file.

6. Why This Is Important for ATO


This topic is frequently asked in MCQs because it is basic OS theory and often tested through definitions, categories,
and examples.
If you understand system calls well, the next topics like processes, threads, and IPC become much easier.

7. Short Revision
• System call = request from user program to OS kernel.
• It is the interface between a process and the OS.
• Main types: process control, file, device, information maintenance, communication.
• Examples: fork(), exec(), open(), read(), write(), wait().

Topic Wise Notes Page 4


Processes
23 May 2026 21:28

This is one of the most important OS fundamentals because every


scheduling, thread, deadlock, and memory concept later depends on
it.

1. What is a Process?
A process is defined as a program in execution. A program, when
stored on disk, exists in a passive state. However, once it is loaded
into memory and begins execution, it transforms into an active entity
known as a process.
Key Distinction
Program: A passive collection of instructions.
Process: An active, running instance of a program.

2. Process Components
A typical process comprises several essential components:
Code section
Data section
Heap
Stack
Program counter
CPU registers
These components are crucial for the operating system to monitor
the process's activities and determine its resumption point following
any interruption.

3. Process Control Block (PCB)


The Process Control Block (PCB) is a data structure utilized by the
operating system to store all pertinent information regarding a
process. Essentially, it functions as the process's identity card and
operational record.
Typical PCB Contents
The PCB generally stores the following information:
Process ID
Process state
Program counter

Topic Wise Notes Page 5


Program counter
CPU registers
Scheduling information
Memory management information
Accounting information
I/O status and open files

4. Process States
A process typically transitions through the following states:
New
Ready
Running
Waiting / Blocked
Terminated

State Definitions
New: The process is in the creation phase.
Ready: The process is awaiting CPU allocation.
Running: The process is currently executing on the CPU.
Waiting/Blocked: The process is paused, awaiting an I/O operation
or a specific event.
Terminated: The process has completed its execution.

5. Context Switching
Context switching is the mechanism by which the operating system
saves the state of one process and restores the state of another,
enabling the CPU to alternate between them. The information saved
during this process is stored within the PCB.

Triggers for Context Switching


Context switching occurs due to various events:
Expiration of a time slice.
A higher-priority process becoming ready for execution.
A process initiating a wait for an I/O operation.
The occurrence of an interrupt.

6. Important Examination Points


A process represents an active program.
The PCB stores information relevant to a process.
Process states include New, Ready, Running, Waiting, and
Topic Wise Notes Page 6
Process states include New, Ready, Running, Waiting, and
Terminated.
Context switching relies on the PCB.
A process and a program are distinct concepts.

7. Short Revision
A program residing on disk is passive.
A program undergoing execution is a process.
The PCB serves as the repository for process information.
The operating system manages changes in process states.
Context switching involves saving one process and loading another.
The subsequent topic for study is Threads.

Topic Wise Notes Page 7


Threads
23 May 2026 21:33

The topic of Threads is crucial as it elucidates how a singular process


can efficiently execute multiple tasks concurrently within the same
program.
1. Definition of a Thread
A thread represents the most granular unit of execution contained
within a process. It is also referred to as a lightweight process due to
its propensity to share numerous resources with other threads
belonging to the same process.
Fundamental Distinction
Process: An autonomous program operating in execution.
Thread: A discrete execution path operating within a process.

2. Advantages of Utilizing Threads


Threads enhance performance by facilitating the concurrent
execution of multiple tasks within a single process. They prove
particularly beneficial when a program is required to manage
simultaneous operations, such as processing user input, conducting
background tasks, and generating output.

3. Shared Resources Among Threads


Threads originating from the same process share the following
resources:
• Code section
• Data section
• Heap
• Open files
• Other process resources
• Conversely, each thread maintains its distinct:
• Program counter
• Register set
• Stack

4. Classifications of Threads
The two primary categories of threads are:
• User-level threads

Topic Wise Notes Page 8


• User-level threads
• Kernel-level threads

A. User-Level Threads
These threads are managed by a user-level thread library, and the
operating system kernel is not directly cognizant of their existence.
While they offer faster creation and switching times, the blocking of
a single thread in many models can lead to the entire process
becoming blocked.

B. Kernel-Level Threads
Managed directly by the operating system kernel, these threads
enable superior scheduling and genuine parallelism across multiple
CPUs. However, they are associated with greater overhead
compared to user-level threads.

5. Thread vs Process
Feature Process Thread
Memory Separate Shared memory with other threads
memory space in same process [4][6]
Overhead Higher Lower [1][5]
Independenc Independent Not independent like a process [1]
e [7]
Communicati Slower, more Easier and faster because memory is
on costly shared [1][6]

6. Multithreading
Multithreading involves the subdivision of a process into multiple
threads to allow for their concurrent execution. This approach
significantly improves responsiveness and efficiency, especially in
applications that necessitate the performance of more than one task
simultaneously.

7. Key Exam Considerations


A thread constitutes a distinct flow of execution within a process.
Threads share a common address space.
Each thread possesses its own program counter, stack, and registers.
User-level threads are administered by thread libraries.

Topic Wise Notes Page 9


User-level threads are administered by thread libraries.
Kernel-level threads are managed by the operating system kernel.
Threads are inherently more lightweight and operate at a faster pace
than processes.

8. Concise Review
Thread = smallest unit of execution.
Lightweight process = thread.
Threads share code and resources.
Each thread possesses its own program counter, registers, and stack.
There are two types: user-level and kernel-level.
Following this, our next topic will be Inter-process Communication
(IPC).

Topic Wise Notes Page 10


IPC
23 May 2026 22:07

1. What is IPC?
IPC(Inter-Process Communication) is a set of mechanisms provided by the
operating system that allows processes to communicate and synchronize with one
another.
It is needed because separate processes often need to share information or coordinate
tasks.

2. Why IPC is needed


Processes may run at the same time and may need to:
• Share data.
• Send messages.
• Coordinate execution.
• Avoid conflicts while using shared resources.

3. Main IPC methods


The common IPC methods are:
• Pipes.
• Message passing / message queues.
• Shared memory.
• Sockets.
• Semaphores for synchronization.

4. Pipes
A pipe is a unidirectional communication channel used for communication between
related processes. Data written at one end is read from the other end in sequence.
Key points
• Simple and fast.
• Usually used between parent-child processes.
• Anonymous pipes are temporary.
• Named pipes or FIFOs can be used by unrelated processes too.

5. Message passing
In message passing, processes communicate by sending and receiving messages
through the OS. This method does not require shared memory, which makes it safer and
easier to manage in many systems.
Key points
• Uses send and receive operations.
• Can be synchronous or asynchronous.
• Often used when processes are separate and do not share memory.

6. Shared memory
Shared memory allows two or more processes to access the same memory region. It is
the fastest IPC method because data does not need to be copied between processes.
Important caution: Because multiple processes can access the same memory,
synchronization is required to avoid inconsistency and race conditions.

7. Sockets
Sockets are communication endpoints used for communication on the same machine or

Topic Wise Notes Page 11


Sockets are communication endpoints used for communication on the same machine or
over a network. They are very important in client-server systems and network
applications.

8. Semaphores
Semaphores are not a communication channel in the same way as pipes or shared
memory, but they are very important for synchronization. They help control access to
shared resources so that processes do not interfere with each other.

9. IPC comparison
Method Speed Shared memory Best use
needed
Pipe Fast No Simple related-process
communication
Message Moderate No Safe communication through
passing OS
Shared Fastest Yes Heavy data exchange
memory
Socket Moderate No Local or network
communication
Semaphore N/A for data No Synchronization and locking
transfer

10. Exam points to remember


• IPC means inter-process communication.
• It allows communication and synchronization.
• Pipes are unidirectional.
• Shared memory is fastest but needs synchronization.
• Sockets are used for network-style communication.
• Semaphores help prevent race conditions.

11. Short revision


• IPC = process communication and coordination.
• Main types: pipes, message passing, shared memory, sockets.
• Fastest IPC: shared memory.
• Safest and simpler for OS-managed exchange: message passing.
• Synchronization tool: semaphore.

Topic Wise Notes Page 12


Concurrency and Synchronization – Clean Notes
24 May 2026 14:36

1. What is concurrency?
• Concurrency means multiple processes or threads are making progress during the same time period, even if they are not literally executing at the
exact same instant on a single CPU.
• It helps improve CPU utilization and makes the system more responsive.

2. Why is synchronization needed?


• When multiple processes share data or resources, unsynchronized access can lead to inconsistent or incorrect results.
• Synchronization ensures that shared resources are used in an orderly and correct manner, preventing conflicts.

3. Race condition
• A race condition occurs when the final outcome depends on the order or timing with which two or more processes or threads acc ess shared data.
• Because the order is unpredictable, it can produce wrong or inconsistent results.

4. Critical section
• A critical section is the part of a program where shared resources (like shared variables, files, etc.) are accessed.
• If the resource is not sharable, only one process or thread should execute its critical section at a time.
Critical section problem – requirements :
• Mutual exclusion: Only one process is in the critical section at a time.
• Progress: If no process is in the critical section, a process that wants to enter should not be postponed indefinitely.
• Bounded waiting: There is a limit on how many times other processes can enter their critical sections after a process has req uested to enter its
critical section.

5. Mutual exclusion
• Mutual exclusion means that only one process or thread can enter the critical section at a time.
• This prevents two processes from changing the same shared data at the same time, avoiding inconsistency.

6. Synchronization tools
Common tools used to achieve synchronization are :
• Mutex
• Semaphore
• Monitor
• Locks
• Atomic operations
Mutex
• A mutex (mutual exclusion lock) is a binary lock used to protect a critical section.
• Only one thread or process can hold the mutex at a time; others must wait.
Semaphore
• A semaphore is an integer-based synchronization mechanism used to control access to resources.
• Binary semaphore: behaves like a mutex (only 0 or 1).
• Counting semaphore: allows a limited number of concurrent accesses to a resource (e.g., up to N threads).
Monitor
• A monitor is a higher-level synchronization construct that groups shared data and the procedures that operate on that data, providing automatic
mutual exclusion.

7. Common exam terms (one-liners)


• Race condition: Wrong or unpredictable outcome due to timing/order of execution.
• Critical section: Part of code where shared resources are accessed.
• Mutual exclusion: Only one process/thread accesses the critical section at a time.
• Semaphore: Counter-based mechanism to control access to resources.
• Mutex: Binary lock to enforce mutual exclusion.
• Monitor: High-level synchronization construct wrapping data + operations.

8. Quick revision points


• Concurrency: Overlapping progress of multiple processes/threads.
• Synchronization: Correct coordination when using shared resources.
• Race condition: Result depends on execution order, leading to errors.
• Critical section: Section of code that accesses shared resources.
• Mutex and semaphores are the most common synchronization tools in exam questions.

Topic Wise Notes Page 13


Deadlock
24 May 2026 15:11

Deadlock – Clean Notes


1. What is deadlock?
Deadlock is a situation where two or more processes are stuck forever because each is
waiting for a resource held by another process.
As a result, no process can proceed, and the system becomes blocked.

2. Simple example
Process [P1] holds resource [R1] and is waiting for [R2].
Process [P2] holds resource [R2] and is waiting for [R1].
Both processes wait indefinitely → deadlock occurs.

3. Necessary conditions for deadlock


Deadlock occurs only if all four conditions are present simultaneously:
-Mutual exclusion
-Hold and wait
-No preemption
-Circular wait

Meaning of each condition


-Mutual exclusion: Some resources can be used by only one process at a time.
-Hold and wait: A process holds at least one resource while waiting for additional
resources.
-No preemption: Resources cannot be forcibly taken; they must be released voluntarily.
-Circular wait: A circular chain of processes exists, where each process is waiting for a
resource held by the next process.

4. Deadlock handling methods


Operating systems handle deadlock using four main approaches:
-Prevention
-Avoidance
-Detection
-Recovery

A. Prevention
The system is designed so that at least one of the four necessary conditions never occurs.
Example: Prevent hold-and-wait by forcing processes to request all resources at once.

B. Avoidance
The OS checks every request and ensures the system remains in a safe state before
allocating resources.
Topic Wise Notes Page 14
allocating resources.
If unsafe, the request is denied.

C. Detection
The OS allows deadlock to occur.
Later, it detects deadlock using algorithms (e.g., resource allocation graph).

D. Recovery
After detection, the system recovers by:
Terminating processes, or
Preempting (taking back) resources.

5. Banker’s algorithm
Banker’s algorithm is a deadlock avoidance algorithm.
It checks whether granting a request keeps the system in a safe state.

Important terms
-Safe state: There exists at least one sequence of execution where all processes can
complete without deadlock.
-Unsafe state: The system may lead to deadlock (not necessarily deadlock yet).

6. Resource allocation graph


A resource allocation graph (RAG) represents processes and resources using nodes and
edges.
It helps in understanding and detecting deadlocks, especially in conceptual questions.

7. Exam points to remember


Deadlock = permanent waiting state.
-All four conditions must hold together.
-Prevention breaks at least one condition.
-Avoidance uses safe/unsafe state concept.
-Banker’s algorithm is used in avoidance.
-Detection + recovery is another strategy.

8. Quick revision
-Deadlock: Processes wait indefinitely for each other.
-Conditions: Mutual exclusion, hold and wait, no preemption, circular wait.
-Methods: Prevention, avoidance, detection, recovery.
-Banker’s algorithm: Deadlock avoidance technique.

Topic Wise Notes Page 15


CPU Scheduling
25 May 2026 13:19

1. What is CPU scheduling?


• CPU scheduling is the method by which the operating system selects one process from the ready queue and allocates the CPU to it.
• The main goal is to keep the CPU as busy as possible and improve overall system performance.

2. Why scheduling is needed


• In a multiprogramming system, many processes may be ready at the same time, but only one CPU is available.
• Therefore, the OS must decide the order of execution in a fair and efficient way.

3. Types of CPU scheduling


• CPU scheduling algorithms are broadly divided into:
• Non- pre-emptive
• Pre-emptive

Non-pre-emptive
• Once a process gets the CPU, it keeps it until it finishes or blocks (e.g., for I/O).
Pre-emptive
• A running process can be interrupted, and the CPU can be given to another process (for example, if a higher-priority process arrives).

4. Important scheduling algorithms


A. FCFS (First Come First Serve)
• Processes are executed in the order they arrive in the ready queue.
• Very simple, but can cause long waiting times if a long job arrives first (convoy effect).
B. SJF (Shortest Job First)
• Chooses the process with the smallest CPU burst time.
• Minimizes average waiting time but may cause starvation for long processes.
C. Priority Scheduling
• The process with the highest priority (often smallest priority number) is selected first.
• Low-priority processes may starve if high-priority processes keep arriving.
D. Round Robin (RR)
• Each process gets the CPU for a fixed time quantum in cyclic order.
• Widely used in time-sharing systems because it is fair and gives good response time.
E. Multilevel Queue
• Processes are divided into separate queues (e.g., foreground, background), each with its own scheduling policy.
F. Multilevel Feedback Queue
• Processes can move between queues based on their behaviour and CPU usage.
• More flexible than fixed multilevel queue scheduling.

5. Scheduling criteria
Common criteria to judge scheduling algorithms:
• CPU utilization
• Throughput
• Turnaround time
• Waiting time
• Response time
Key definitions
• Turnaround time = completion time − arrival time.
• Waiting time = total time a process spends in the ready queue.
• Response time = time from arrival until the first time the process gets the CPU.

6. Exam points to remember


• CPU scheduling chooses the next process from the ready queue.
• FCFS is non-pre-emptive.
• SJF selects the process with the shortest burst time.
• Round Robin uses a fixed time quantum.
• Priority scheduling can cause starvation of low-priority processes.
• Response time is the delay before the process first gets the CPU.

7. Short revision (quick recap)


• CPU scheduling = choosing a ready process for CPU execution.
• Two main types = pre-emptive and non-pre-emptive.
• FCFS = first arrival is served first, non-pre-emptive.
• SJF = process with shortest CPU burst first.
• Round Robin = each process gets a fixed time slice (quantum).
• Key metrics = waiting time, turnaround time, response time.

Topic Wise Notes Page 16


Topic Wise Notes Page 17
I/O Scheduling
29 May 2026 11:30

1. What is I/O Scheduling?


I/O scheduling is the method the Operating System (OS) uses to decide the order in which disk input/output requests are executed.
Why efficiency matters: Disk access (mechanical movement) is significantly slower than CPU operations. A good scheduling policy optimizes this
gap and improves overall system efficiency.

2. Why is it Needed?
• Reduces Seek Time: If disk requests are served randomly, the disk head moves too much, causing large seek times and slow performance.
• Minimizes Head Movement: The main goal of any I/O scheduling algorithm is to minimize the total physical movement of the disk head.
• Improves Throughput: Efficient scheduling ensures faster data retrieval and better system responsiveness.

3. Main Algorithms
A. FCFS (First Come First Serve)
• Concept: Serves requests strictly in the exact order they arrive.
• Pros: Simple to implement and fair to all requests (no favoritism).
• Cons: Highly inefficient; does not optimize or reduce seek time.
B. SSTF (Shortest Seek Time First)
• Concept: Chooses the request that is closest to the current position of the disk head.
• Pros: Significantly improves performance compared to FCFS.
• Cons: Can cause starvation for requests that are located far away from the head's current position.
C. SCAN (Elevator Algorithm)
• Concept: The disk head moves in one direction, servicing all requests along the way until it reaches the absolute end of the disk, the n reverses
direction.
• Pros: Provides a more uniform waiting time than SSTF and prevents starvation.
D. C-SCAN (Circular SCAN)
• Concept: The head moves in one direction servicing requests, and when it reaches the end, it immediately jumps straight back to the be ginning
without servicing any requests on the return trip.
• Pros: Provides a much more uniform and predictable waiting time than standard SCAN.
E. LOOK
• Concept: Similar to SCAN, but with a smart tweak: the head only moves as far as the last request in the current direction. It reverses immediately
without traveling to the physical boundary of the disk.
• Pros: Avoids unnecessary mechanical movement to the extreme ends of the disk.
F. C-LOOK (Circular LOOK)
• Concept: The circular version of LOOK. It moves in one direction servicing requests up to the last request, then jumps directly back t o the very first
request on the other end (not the physical edge).
• Pros: The most optimized version among these, eliminating extra overhead movement completely.
4. Exam Comparison Table
Algorithm Key Idea Main Weakness
FCFS Serves in arrival order High seek time
SSTF Serves nearest request first Causes starvation
SCAN Moves like an elevator (goes to physical end) Edge requests may wait longer
C-SCAN One-way sweep with an immediate jump back Extra jump overhead to the boundary
LOOK Moves only up to the last request Slightly more complex logic
C-LOOK Circular version of LOOK (jumps to first/last request) Slightly more complex logic

5. Important Points to Remember (Exam Pointers)


• Alternative Name: Disk scheduling is also widely known as I/O scheduling.
• Core Objective: Always remember the primary goal is to reduce seek time and head movement.
• Starvation Risk: SSTF is notorious for causing starvation.
• Fairness: SCAN and C-SCAN are considered fairer algorithms than SSTF.
• Optimization: LOOK and C-LOOK are advanced versions designed specifically to avoid useless movement to absolute disk ends.
6. Short Revision (Quick Revision Notes)
• I/O Scheduling = Ordering disk requests.
• FCFS = Simplest, but highly inefficient.
• SSTF = Nearest request first (Starvation danger!).
• SCAN = Elevator algorithm (Goes till the physical end).
• C-SCAN = One direction service, then quick jump back to start.
• LOOK / C-LOOK = Smarter SCAN / C-SCAN that stops right at the last request instead of hitting the walls.

From <[Link]

Topic Wise Notes Page 18


Memory management
02 June 2026 17:35

1. What is memory management?


• Memory management is the operating system (OS) function that controls and
organizes primary memory (RAM) so that multiple programs can run safely and
efficiently.
• It decides which process gets memory, when it gets memory, and how much
memory it gets.

2. Why is it needed?
• The OS must prevent programs from interfering with one another, use RAM
efficiently, and support multiple processes at the same time.
• Memory management also supports memory protection, swapping, and virtual
memory mechanisms.

3. Basic memory allocation methods


A. Single contiguous allocation
• Memory is divided into two parts: one for the OS and one for a single user process.
• This method is very simple but does not support multiprogramming well.
B. Fixed partition allocation
• Memory is divided into fixed-size partitions, and each partition can hold exactly one
process.
• This can lead to internal fragmentation when a process is smaller than the partition it
occupies.
C. Dynamic partition allocation
• Memory is divided into variable-sized blocks based on the actual needs of
processes.
• It can reduce internal waste but may cause external fragmentation over time.

4. Placement strategies
When a process requests memory, the OS may choose a free block using:
• First fit: Choose the first block that is large enough.
• Best fit: Choose the smallest block that is large enough.
• Worst fit: Choose the largest available block.
• Next fit: Similar to first fit, but the search starts from where the last allocation ended.

5. Fragmentation
• Fragmentation means that some parts of memory are wasted and cannot be used
effectively.
Types:
• Internal fragmentation: Wasted space inside an allocated block because the block is
larger than the process.
• External fragmentation: Free memory exists but is split into many small pieces, so it
is hard to find a big enough continuous block for a process.

6. Paging and segmentation


Paging
• Paging divides logical memory into fixed-size pages and physical memory into
frames, then maps pages to frames.

Topic Wise Notes Page 19


frames, then maps pages to frames.
• It helps remove external fragmentation because any page can go into any frame.
Segmentation
• Segmentation divides memory into logical, variable-sized segments such as code,
data, and stack.
• It matches the program’s logical structure better but can suffer from external
fragmentation.

7. Virtual memory and demand paging


Virtual memory
• Virtual memory lets a program run even when not all of it is loaded in physical RAM
at the same time.
• The OS uses disk space as an extension of memory and brings required pages into
RAM when needed.
Demand paging
• In demand paging, a page is loaded into RAM only when it is actually accessed by
the program.
• This improves memory usage and allows more processes to reside in memory
logically at once.

8. Exam points to remember


• Memory management controls how primary memory (RAM) is used.
• It supports protection, swapping, and virtual memory.
• Single contiguous allocation is the simplest allocation method.
• Fixed partition allocation can cause internal fragmentation.
• Paging uses fixed-size pages and frames.
• Segmentation uses logical, variable-sized segments.
• Virtual memory effectively extends main memory using disk space.

9. Short revision (one-liners)


• Memory management = OS control of RAM.
• Contiguous allocation = one continuous user block.
• Paging = fixed-size pages and frames.
• Segmentation = logical, variable-sized parts (code, data, stack).
• Fragmentation = wasted memory space.
• Virtual memory = illusion of large RAM using RAM + disk.

From <[Link]

Topic Wise Notes Page 20


File system
02 June 2026 17:37

1. What is a file?
• A file is a named collection of related information stored on secondary storage like a
hard disk or SSD.
• It can contain text, program code, images, audio, video, or any other type of data.

2. What is a file system?


• A file system is the part of the operating system that manages how files and
directories are stored, named, and organized on disk.
• It allows users and programs to create, delete, read, write, and arrange files in a
structured way (e.g., folders).

3. Main functions of a file system


Typical responsibilities of a file system include:
• File naming and identification
• File creation and deletion
• File access (read, write, append, etc.)
• Directory creation and management
• Disk space allocation for files
• Free-space tracking and management
• Protection and access control (permissions)
• Recovery and consistency handling after crashes

4. File allocation methods


Most syllabi focus on three major file allocation methods.
A. Contiguous allocation
• Each file occupies a set of consecutive disk blocks.
• It is simple and offers very fast sequential and random access but can cause
external fragmentation and difficulty when a file needs to grow.
B. Linked allocation
• A file is stored as a linked list of disk blocks that may be scattered anywhere on the
disk; each block points to the next block.
• This avoids external fragmentation and supports easy file growth but gives poor
random access because blocks must be followed one by one.
C. Indexed allocation
• An index block (or table) stores all the pointers to the file’s data blocks.
• This supports efficient random access and avoids external fragmentation, but
requires extra space and management for the index block itself.

5. Directory structure
• Directories are used to organize and group files and are often implemented internally
as:
• Linear list of file entries
• Hash table of file entries
• A linear list is easy to implement but slower to search because the system may have
to scan many entries.
• A hash table speeds up search by mapping names to locations but can suffer from
collisions and may use fixed-size tables.

Topic Wise Notes Page 21


6. Free-space management
• The OS must track which disk blocks are free so it can allocate them to new or
growing files.
Common methods:
• Bit vector (bitmap): A bit array where each bit represents a block (0 = free, 1 = used);
makes it easier to find contiguous free blocks.
• Free list: A linked list or list of free blocks; simple to maintain but harder to find large
continuous free regions.

7. Recovery and consistency


• File systems must deal with crashes, power failures, and inconsistent states on disk.
• Techniques like consistency checking tools and journaling help detect, repair, or
prevent file system corruption after failures.

8. Exam points to remember


• File = named data stored on disk.
• File system = OS component that manages files and directories.
• Main allocation methods = contiguous, linked, indexed.
• Contiguous allocation = very fast access but causes external fragmentation and
growth issues.
• Linked allocation = flexible and no external fragmentation but poor random access.
• Indexed allocation = balanced, supports random access, needs extra index space.
• Directories commonly use linear lists or hash tables to store file entries.

9. Short revision (one-liners)


• File system = stores and organizes files on disk.
• Contiguous allocation = file blocks stored together, very fast.
• Linked allocation = file blocks form a chain via pointers.
• Indexed allocation = index block holds addresses of all file blocks.
• Directories = help name, group, and locate files.
• Free-space management = tracks unused disk blocks for future allocation.

From <[Link]

Topic Wise Notes Page 22

You might also like