Operating System and its Functions
Operating System and its Functions
Definition:
An Operating System (OS) is a system software that acts as an
interface between the user and the computer hardware. It provides an
environment in which a user can execute programs conveniently and
efficiently.
Example:
Popular operating systems include Windows, Linux, macOS, Android,
and iOS.
✅ Multiprogramming Systems:
✅ Time-Sharing Systems:
Interactive.
Multiple users share system resources simultaneously.
✅ Real-Time Systems:
1
Provides immediate response to input.
Below are the major functions, each with sub-points and explanations:
Key Points:
Key Points:
2
Allocation & Deallocation: Allocates memory to processes and
frees it when not needed.
Swapping: Moves processes between main memory and disk.
Virtual Memory: Allows execution of processes larger than
physical memory using paging or segmentation.
Key Points:
Key Points:
Key Points:
3
4.6 User Interface
Key Points:
Summary Table
Function Description
Process
Handles processes, scheduling, deadlocks
Management
Memory Allocates/deallocates memory, virtual
Management memory
Manages files, directories, access
File Management
permissions
Device
Controls I/O devices, drivers, spooling
Management
Security Protects data and system integrity
User Interface CLI and GUI for user interaction
4
Function Description
Networking Enables system communication
Accounting Tracks resource usage
Error Handling Detects and recovers from errors
Definition:
A batch operating system executes a batch of jobs without user
interaction during execution.
Key Points:
Advantages:
Disadvantages:
5
Definition:
Allows direct interaction between the user and the computer during
program execution.
Key Points:
Advantages:
Disadvantages:
Definition:
Allows multiple users to share system resources simultaneously,
giving the illusion of exclusivity.
Key Points:
Advantages:
Disadvantages:
6
4 Real-Time Operating System (RTOS)
Definition:
Designed to process real-time applications with strict timing constraints.
Key Points:
Advantages:
Disadvantages:
Complex to design.
Expensive hardware requirements.
5 Multiprocessor Systems
Definition:
Uses two or more processors sharing the same memory and resources.
Key Points:
Advantages:
Disadvantages:
7
Complex OS design.
Synchronization issues.
6 Multiuser Systems
Definition:
Allows multiple users to access the computer system simultaneously.
Key Points:
Advantages:
Resource sharing.
Cost-effective for organizations.
Disadvantages:
Security concerns.
Resource allocation challenges.
7 Multiprogramming Systems
Definition:
Multiple programs reside in memory at the same time, and CPU switches
between them.
Key Points:
Advantages:
Disadvantages:
8
Complex memory management.
Risk of deadlocks.
8 Multithreaded Systems
Definition:
An extension of multitasking where a single process can have multiple
threads executing simultaneously.
Key Points:
Advantages:
Disadvantages:
Complex to program.
Risk of data inconsistency (race conditions).
Summary Table
9
Type of OS Key Feature Example
Multiple users
Multiuser Unix servers
simultaneously
IBM 360 (early
Multiprogramming Multiple jobs in memory
systems)
Multiple threads per
Multithreaded Java Threads
process
Definition
Key Feature:
Diagram
+-------------------------+
| User Programs / Shell | ← Top Layer (User Interaction)
+-------------------------+
| System Utilities | ← Service Layer
+-------------------------+
10
| File System | ← File Management Layer
+-------------------------+
| I/O Management | ← I/O Layer
+-------------------------+
| Memory Management | ← Memory Layer
+-------------------------+
| Process Management | ← Process Layer
+-------------------------+
| Hardware Interaction | ← Hardware Abstraction Layer
+-------------------------+
| Hardware | ← Bottom Layer
+-------------------------+
Advantages
Disadvantages
11
Allocates and deallocates memory as needed.
Implements virtual memory (if supported).
(f) Networking
Service Description
Program Loads and runs programs; provides environment
Execution for process execution.
12
Service Description
Handles input/output requests, including device
I/O Operations
drivers.
File System Provides file operations like create, delete,
Manipulation read, write, and permissions.
Communication Enables processes to communicate (via shared
Services memory or message passing).
Detects and recovers from system and application
Error Detection
errors.
Resource Manages CPU time, memory, and I/O devices among
Allocation users/programs.
Security & Ensures only authorized access to resources and
Protection protects user data.
Summary Table
Section Description
Layered Organizes OS into hierarchical layers for
Structure modularity and abstraction.
System Process, Memory, File, I/O, Storage,
Components Networking, Security.
Execution, I/O handling, File management,
OS Services Communication, Error detection, Security,
etc.
4 Reentrant Kernels
Definition:
A reentrant kernel is a kernel that can be safely shared among
multiple processes. It means that multiple processes can execute kernel
code simultaneously without interfering with each other.
Key Features:
13
Code Sharing: Kernel code is read-only, so multiple processes
can use I simultaneously.
No Global Variables: Uses private process stacks or context
blocks instead of global data.
Concurrency Support: Supports interrupts and system calls
even while another process is using the kernel.
Advantages:
Disadvantages:
Example:
Modern Unix and Linux kernels are reentrant because they allow
multiple processes to be inside the kernel concurrently.
5 Monolithic Systems
Definition:
A monolithic kernel is a single large process that runs entirely in a single
address space in kernel mode. All OS services—such as process
management, file system, device drivers, etc.—run together.
Key Features:
✅ Entire OS runs in kernel mode.
✅ All services are tightly coupled.
✅ Communication between services uses direct procedure calls.
Advantages:
Disadvantages:
14
Difficult to maintain and debug (a bug in one service can crash
the entire OS).
Adding new features can be challenging.
Less modular, harder to port to different hardware.
Examples:
6 Microkernel Systems
Definition:
A microkernel structure minimizes the core kernel to essential services
like inter-process communication (IPC), basic scheduling, and low-
level hardware management. Other services (file systems, device
drivers, network stack) run in user space as separate processes.
Key Features:
✅ Small, minimal kernel running in kernel mode.
✅ Most OS services run as user-space servers.
✅ Communication between services uses message passing.
Advantages:
Disadvantages:
Examples:
15
UNIT = 2
Concurrent Processes
1 Process Concept
Definition:
A process is an instance of a program in execution, with its own address
space, stack, data, and code.
Key Points:
✅ Contains program counter, registers, and variables.
✅ OS uses a Process Control Block (PCB) to manage each process.
✅ Processes may be independent or cooperating (e.g., sharing data).
2 Principle of Concurrency
Definition:
Concurrency means multiple processes execute in overlapping time
periods—either actually simultaneously (on multiprocessor systems) or
by rapid switching (time-sharing).
Key Points:
✅ Enhances resource utilization (CPU, I/O).
✅ Supports multi-user systems.
✅ Introduces challenges like race conditions, deadlocks, and
synchronization.
3 Producer/Consumer Problem
16
Definition:
A classic example of inter-process communication (IPC) where:
Key Issues:
✅ Ensuring the producer doesn’t overwrite a full buffer.
✅ Ensuring the consumer doesn’t read an empty buffer.
Solutions:
4 Mutual Exclusion
Definition:
Ensures that only one process at a time can access a shared resource
(e.g., a variable or file).
Critical Points:
✅ Necessary to prevent race conditions.
✅ Implemented using critical sections.
Definition:
A critical section is a part of the program where the process accesses
shared resources.
17
6 Dekker’s Solution
Definition:
One of the first software solutions to the critical section problem for two
processes.
Key Points:
✅ Uses flags to indicate a process’s desire to enter the critical section.
✅ Uses a turn variable to decide who enters next.
✅ Ensures mutual exclusion, progress, and bounded waiting.
Drawback:
7 Peterson’s Solution
Definition:
A simpler and elegant solution to the two-process critical section
problem.
Key Points:
✅ Uses two flags (flag[0], flag[1]) and a turn variable.
✅ Ensures mutual exclusion, progress, and bounded waiting.
Algorithm Sketch:
flag[i] = true;
turn = j;
while (flag[j] && turn == j);
// critical section
flag[i] = false;
8 Semaphores
18
Definition:
A synchronization primitive introduced by Dijkstra to control access to
shared resources.
Types:
Operations:
9 Test-and-Set Operation
Definition:
A hardware atomic instruction used for implementing mutual exclusion.
Working:
✅ Tests the lock variable and sets it atomically.
✅ If lock is 0 (unlocked), sets it to 1 (locked) and proceeds.
✅ If lock is already 1, keeps spinning (busy waiting).
Drawbacks:
Summary Table
Concept Description
A program in execution with its own
Process Concept
resources and state.
Overlapping execution of processes,
Concurrency
enabling multitasking.
Producer/Consumer Classic IPC problem involving a buffer
19
Concept Description
shared by producer and consumer.
Ensures exclusive access to shared
Mutual Exclusion
resources.
Part of code accessing shared resources;
Critical Section
must be protected.
First software solution for 2-process
Dekker’s Solution
mutual exclusion.
Peterson’s Simpler solution using flags and turn
Solution variable.
OS synchronization primitive (binary or
Semaphores
counting).
Atomic hardware instruction for mutual
Test-and-Set
exclusion.
Problem Statement:
Key Issues:
20
✅ Deadlock: If every philosopher picks up their left fork and waits for
the right one, deadlock occurs.
Requirements:
Possible Solutions:
Example (Semaphore):
// Pseudocode
Semaphore forks[N]; // Initialize all forks to 1
Semaphore mutex = N-1; // At most N-1 philosophers at the
table
// Philosopher i's algorithm
wait(mutex);
wait(forks[i]);
wait(forks[(i+1)%N]);// eat
signal(forks[i]);
signal(forks[(i+1)%N]);
signal(mutex);
Diagram:
[P0]---fork---[P1]
| |
fork fork
| |
21
[P4]---fork---[P2]
| |
fork fork
| |
[P3]---fork---[P4]
Problem Statement:
Key Issues:
Scenario:
Example (Semaphore):
Semaphore customers = 0;
22
Semaphore barber = 0;
Semaphore mutex = 1;
int waiting = 0, chairs = n;
// Customer's process
wait(mutex);
if (waiting < chairs) {
waiting++;
signal(customers); // Wake barber
signal(mutex);
wait(barber); // Wait for barber to be ready
// get haircut
} else {
signal(mutex);
// leave shop
}
// Barber's process
while (true) {
wait(customers); // Sleep if no customers
wait(mutex);
waiting--;
signal(barber); // Call customer for haircut
signal(mutex);
// cut hair
}
Comparison Table
23
INTERPROCESS COMMUNICATION (IPC)
Definition:
Interprocess Communication (IPC) refers to the mechanisms an
Operating System provides to allow processes to exchange data and
synchronize their actions.
1 IPC Models
Concept:
Processes communicate by sending and receiving messages (packets of
data).
Advantages:
Disadvantages:
❌ Slower than shared memory (due to copying overhead).
❌ Complex message management (buffering, delivery).
Concept:
Processes share a region of memory.
Advantages:
24
Faster than message passing (no copying overhead).
Direct data exchange.
Disadvantages:
❌ Complex synchronization (critical section problem).
❌ Harder to debug race conditions.
2 IPC Schemes
A. Direct Communication
Concept:
Example:
send(P1, msg)
receive(P2, msg)
B. Indirect Communication
Concept:
Example:
send(mailbox1, msg)
receive(mailbox1, msg)
Type Description
25
Sender waits until receiver is ready. Receiver
Synchronous
waits if no message.
Sender continues without waiting; receiver
Asynchronous
collects messages later.
D. Buffering
Concept:
Types of buffers:
26
PROCESS GENERATION
Definition:
Process generation refers to how new processes are created in the
operating system.
1. System Initialization
2. User Request
Parent-Child Relationship:
2 Process Hierarchies
27
1. Hierarchical Model:
2. Non-Hierarchical Model:
pid_t pid;
pid = fork();
if (pid == 0) {
// Child process
exec("/bin/ls");
} else {
// Parent process
wait();
}
1 IPC Models
Diagram:
28
| A | | B |
+---------+ +---------+
Explanation:
Diagram:
Explanation:
2 IPC Schemes
Direct Communication
Diagram:
Notes:
29
Explicitly names sender and receiver.
Diagram:
+------------+
| Mailbox |
+------------+
/ \
Process A Process B
| |
send(msg) receive(msg)
Notes:
Buffering
Types:
30
1 Fork-Exec Model (UNIX)
Flowchart:
Flowchart:
Parent Process
|
| fork()
↓
+----------------+
| Child Process |
| (duplicate of |
| parent) |
+----------------+
|
| exec(program)
↓
+----------------+
| New Program |
| (e.g. /bin/ls) |
+----------------+
Explanation:
Diagram:
31
| |
P1 P2
|
P3
Explanation:
pid_t pid;
pid = fork();
if (pid == 0) {
// Child process
exec("/bin/ls");
} else {
// Parent process
wait(); // waits for child to complete
}
Summary Table
UNIT = 3
32
CPU SCHEDULING
1 Scheduling Concepts
Definition:
Key Concepts:
Arrival Time (AT): Time when process enters the ready queue.
2 Performance Criteria
Criterion Description
CPU Keep CPU as busy as possible (e.g., 90–
Utilization 100%).
Number of processes completed per unit
Throughput
time.
Turnaround Time from submission to completion of a
Time process.
Time a process spends waiting in the ready
Waiting Time
queue.
Response Time Time from submission to first response.
33
Criterion Description
Fairness Ensures all processes get CPU time fairly.
3 Process States
State Description
New Process is being created.
Ready Process is waiting to be assigned to CPU.
Running Process is currently executing on CPU.
Process is waiting for some event (I/O
Waiting/Blocked
completion).
Terminated Process has finished execution.
Diagram:
+---------+
| New |
+---------+
|
V
+---------+
| Ready |
+---------+
|
V
+---------+
| Running |
+---------+
|
+-------+-------+
| |
V V
34
+---------+ +-----------+
| Waiting | | Terminated|
+---------+ +-----------+
^
|
+---------+
| I/O |
+---------+
Explanation:
5 Schedulers
Schedulers are special system software that select which process to run
next.
Types:
Scheduler Description
Long-Term Selects processes from job pool (on disk) and
Scheduler (Job loads them into main memory. Controls the
Scheduler) degree of multiprogramming.
Medium-Term Handles swapping (suspends/resumes processes)
Scheduler to improve memory management.
Short-Term
Selects from ready processes and assigns CPU.
Scheduler (CPU
Runs very frequently (milliseconds).
Scheduler)
35
Summary Table
Definition:
A Process Control Block (PCB) is a data structure maintained by the OS
for each process. It contains essential information required to manage a
process.
Contents of PCB:
Component Description
Process ID (PID) Unique identifier for the process.
New, Ready, Running, Waiting, or
Process State
Terminated.
Program Counter Address of the next instruction to
(PC) execute.
Values of CPU registers (accumulator,
CPU Registers
index, stack pointer).
Memory Management
Base and limit registers, page tables.
Info
Accounting Info CPU time used, time limits, job priority.
I/O Status Info List of open files, I/O devices assigned.
36
Component Description
Scheduling Info Priority, scheduling state, queues, etc.
Diagram:
+-------------------------+
| Process ID (PID) |
+-------------------------+
| Process State |
+-------------------------+
| Program Counter |
+-------------------------+
| CPU Registers |
+-------------------------+
| Memory Mgmt Info |
+-------------------------+
| Accounting Info |
+-------------------------+
| I/O Status Info |
+-------------------------+
| Scheduling Info |
+-------------------------+
Definition:
It refers to the range of memory addresses a process can access during
its execution.
+--------------------------+
| Text Segment | ← Executable code
+--------------------------+
| Data Segment | ← Global and static variables
+--------------------------+
| Heap Segment | ← Dynamically allocated
memory
37
+--------------------------+
| Stack Segment | ← Function calls, local
variables
+--------------------------+
Explanation:
Each process has its own isolated address space to prevent accidental or
malicious access to others.
Purpose:
To uniquely identify and manage processes.
Components:
Definition:
A thread is the smallest unit of CPU execution within a process.
Types of Threads:
Operation Description
Thread Creation Create new threads within a process.
Thread Termination End a thread’s execution.
Thread Ensure correct sequence of thread
Synchronization execution (e.g., mutex, semaphores).
38
Operation Description
Thread Scheduling Determine which thread runs next.
Scheduling Algorithms
4. Priority Scheduling:
Multiprocessor Scheduling
39
Definition:
Scheduling processes on systems with multiple CPUs or cores.
Key Considerations:
Challenges:
Summary Table
40
1 System Model
Definition:
A system consists of processes and resources. Processes request
resources (like printers, memory, CPU) and may hold some while
requesting more.
Components:
Example Diagram:
+---+ +---+
| P1|----->| R1|
+---+ +---+
|
v
+---+
| P2|
+---+
2 Deadlock Characterization
41
A deadlock situation arises if the following four necessary conditions
hold simultaneously (Coffman Conditions):
Condition Description
Mutual
At least one resource must be non-sharable.
Exclusion
A process holding resources is waiting for
Hold and Wait
additional resources held by others.
No Preemption Resources cannot be forcibly taken away.
A set of processes are waiting in a circular
Circular Wait
chain.
3 Deadlock Prevention
Idea:
Ensure at least one of the Coffman conditions cannot hold.
4 Deadlock Avoidance
Idea:
Use additional information to decide whether or not to grant a request.
Banker’s Algorithm:
Developed by Dijkstra.
42
Checks if granting a resource request leads to a safe state
(no deadlock).
Processes declare maximum resource needs in advance.
5 Deadlock Detection
Idea:
Allow deadlocks to occur but detect and resolve them.
Methods:
Nodes: Processes.
Approaches:
Approach Description
Process Abort one or more processes to break the
Termination cycle.
Resource Temporarily take resources from some
Preemption processes and give them to others.
43
Issues with Recovery:
Summary Table
UNIT = 4
Memory Management
Definition:
The simplest memory management model where the entire memory is
available for a single process at a time.
Characteristics:
44
No OS protection.
No user/application protection.
Application can overwrite OS or other applications.
No concept of multitasking.
Diagram:
+----------------------------+
| Operating System + User |
| Program share same space |
+----------------------------+
Advantages:
✅ Simple to implement.
✅ Direct hardware access.
Disadvantages:
❌ No protection between user and OS memory.
❌ Only one program can run at a time.
❌ Cannot support multitasking.
2 Resident Monitor
Definition:
A basic OS that resides in a fixed portion of memory, leaving the rest
for user processes.
Characteristics:
Diagram:
+----------------------+
| Resident Monitor | ← OS occupies this region
+----------------------+
| User Program Area | ← User program loaded here
45
+----------------------+
Advantages:
✅ OS always available.
✅ Provides minimal protection for OS.
Disadvantages:
❌ No protection between user programs.
❌ No multiprogramming support.
❌ CPU is idle during I/O.
Definition:
Characteristics:
Diagram:
+--------------------+
| OS Memory | ← Resident OS
+--------------------+
| Partition 1 | ← Process 1
+--------------------+
| Partition 2 | ← Process 2
+--------------------+
| Partition 3 | ← Process 3
+--------------------+
46
Advantages:
✅ Simple to implement.
✅ Allows multiprogramming (CPU utilization
improved).
Disadvantages:
❌ Internal Fragmentation: Wasted space within
partitions.
❌ Fixed number of partitions limits process concurrency.
❌ Process size must fit a partition.
Summary Table
Memory
Management Key Features Advantages Disadvantages
Model
No OS
protection,
Bare No multitasking,
direct Simple, direct
Machine no protection
hardware
access
OS occupies
No user-user
Resident fixed OS protection,
protection, no
Monitor memory, user always resident
multiprogramming
area below
Memory
Internal
Fixed divided into Supports
fragmentation,
Partitions fixed multiprogramming
fixed concurrency
partitions
Definition:
Memory is divided into variable-sized partitions according to the size of
incoming processes. This approach eliminates internal fragmentation
but introduces external fragmentation.
47
Working:
Diagram:
+----------------------+
| OS |
+----------------------+
| P1 |
+----------------------+
| P2 |
+----------------------+
| Free Hole |
+----------------------+
| P3 |
+----------------------+
Advantages:
✅ Better memory utilization (less wasted space).
✅ Processes can be allocated memory as needed.
Disadvantages:
❌ External fragmentation.
❌ Need for compaction (to combine free spaces).
2 Protection Schemes
Definition:
Mechanisms to ensure process isolation and prevent one process from
accessing another’s memory.
Methods:
Base and Limit Registers:
48
Hardware checks every address reference.
Diagram:
Physical Memory:
+-----------------------+
| Base | Limit |
| Addr | Register |
+-----------------------+
Advantages:
✅ Prevents processes from corrupting each other.
✅ Provides safe multitasking.
3 Paging
Definition:
Divides memory into fixed-size blocks:
How It Works:
Diagram:
Logical Memory:
Page 0 → Frame 5
Page 1 → Frame 3
Page 2 → Frame 8
Advantages:
✅ Eliminates external fragmentation.
✅ Easy to swap pages in/out.
49
Disadvantages:
❌ Overhead of page tables.
❌ May cause internal fragmentation in the last page.
4 Segmentation
Definition:
Divides memory into variable-sized segments, based on logical
divisions (e.g., code, data, stack).
How It Works:
Diagram:
Segments:
0: Code
1: Data
2: Stack
Advantages:
✅ Reflects logical program structure.
✅ Easier protection (different segments for different
uses).
Disadvantages:
❌ External fragmentation.
❌ Compaction may be needed.
5 Paged Segmentation
Definition:
Combines paging and segmentation:
50
Diagram:
Logical Address:
Segment Number + Page Number + Offset
Advantages:
Definition:
Allows processes to use more memory than physically available by
paging/swapping parts of processes in and out of disk storage.
Key Concepts:
Demand Paging:
Page Fault:
Swapping:
Advantages:
✅ Supports large processes.
✅ Better CPU utilization.
✅ Simplifies programming.
Disadvantages:
❌ Thrashing (too much paging activity).
❌ Disk I/O overhead.
51
Summary Table
1 Demand Paging
Definition:
Demand paging is a virtual memory technique where pages are loaded
into memory only when they are needed, instead of preloading the entire
process.
How It Works:
Diagram:
52
Advantages:
✅ Saves memory by loading only needed pages.
✅ Allows larger programs than physical memory.
Disadvantages:
❌ High initial page fault rate.
❌ Disk I/O overhead.
Key Factors:
✅ Page Fault Rate (PFR):
EAT =
Example:
PFR = 0.001
Then:
EAT=(1−0.001)×100ns+(0.001)×8ms
Observation:
Even a small PFR can greatly slow down the system!
53
3 Page Replacement Algorithms
Purpose:
When memory is full, OS must select a page to evict to make room for a
new page.
Common Algorithms:
4 Thrashing
54
Definition:
Thrashing occurs when the system spends more time swapping pages in
and out than executing processes.
Causes:
Consequences:
❌ CPU utilization drops.
❌ System throughput drops.
Solution:
Definition:
Cache is a small, fast memory between the CPU and main memory that
stores frequently used data and instructions.
Types:
Importance:
✅ Reduces average memory access time.
✅ Exploits locality of reference (next topic).
55
6 Locality of Reference
Definition:
Programs tend to access a small portion of their address space
repeatedly over short periods of time.
Types:
Importance:
✅ Justifies caching and paging.
✅ Helps optimize memory management.
Summary Table
56
I/O MANAGEMENT AND DISK SCHEDULING
A. I/O Devices
B. I/O Subsystems
The I/O subsystem is the OS component that manages all I/O operations
and devices.
Functions:
✅ Manages device drivers.
✅ Handles interrupts.
✅ Provides a buffer between CPU and device.
✅ Offers a uniform interface for devices.
Components:
Device Drivers
Interrupt Handlers
I/O Scheduling
57
2 I/O Buffering
Definition:
Temporary storage area in memory that holds data during I/O transfers.
Types:
Advantages:
✅ Reduces CPU idle time.
✅ Improves device utilization.
Diagram:
+---------------------+
| Application |
| ↓ |
| OS Buffer → Device |
+---------------------+
3 Disk Storage
Definition:
Magnetic disks are the most common secondary storage devices. Data is
stored on rotating platters divided into tracks and sectors.
Key Terms:
✅ Track: Circular path on the surface.
✅ Sector: Subdivision of a track.
✅ Cylinder: Same track on all platters.
✅ Seek Time: Time to move head to the correct track.
✅ Rotational Latency: Time waiting for the sector to
rotate under the head.
✅ Transfer Time: Time to transfer data.
58
4 Disk Scheduling
Purpose:
Optimize disk I/O performance by selecting the order of disk requests.
Algorithms:
Diagram (SCAN):
59
Definition:
Technique for improving disk performance and reliability using multiple
disks in parallel.
RAID Levels:
Advantages:
✅ Improved performance (striping).
✅ Data redundancy (mirroring/parity).
✅ Fault tolerance (some levels).
Disadvantages:
❌ Extra cost (additional disks).
❌ Complex configuration.
Summary Table
60
Topic Key Points
Levels 0, 1, 5, 6; performance and
RAID
reliability.
FILE SYSTEM
1 File Concept
Definition:
A file is a collection of logically related data stored on secondary storage
(e.g., hard disk).
Attributes of a File:
✅ Name: Identifier for the file.
✅ Type: e.g., .txt, .doc, .jpg.
✅ Location: Pointer to the file on disk.
✅ Size: Current size of the file.
✅ Protection: Access permissions (read, write, execute).
✅ Time, date, user ID: For creation and modification
tracking.
File Operations:
✅ Create
✅ Write
✅ Read
✅ Reposition (seek)
✅ Delete
✅ Truncate
Example:
A .txt file storing a note.
File Organization:
How records are arranged within a file.
61
Types:
1. Sequential Access:
3. Indexed Access:
Example Table:
3 File Directories
Purpose:
Organize files in a structured way to manage them efficiently.
Functions:
✅ Store file metadata (name, type, size, location, etc.).
✅ Help with file searching.
✅ Manage file hierarchies (folders and subfolders).
Directory Structures:
✅ Single-level Directory:
62
All files in one directory.
Simple but prone to name conflicts.
✅ Two-level Directory:
✅ Tree-structured Directory:
4 File Sharing
Definition:
Allows multiple users/processes to access the same file concurrently.
Mechanisms:
✅ File locks to avoid conflicts.
✅ Access control lists to manage permissions.
Problems:
❌ Concurrency issues (e.g., two users editing the same file
simultaneously).
❌ Security risks if not managed properly.
Components:
✅ File Control Block (FCB): Stores file metadata like size, location,
63
permissions.
✅ Disk Layout:
Example:
Bitmap-based free space management in Linux ext2.
Purpose:
Protect files from unauthorized access, modification, or deletion.
Mechanisms:
✅ Access Control Lists (ACLs): Define permissions for
users/groups.
✅ Password Protection: Individual file passwords (less common
today).
✅ Encryption: Encrypting file contents for confidentiality.
Summary Table
64
Topic Key Points
File Concept Attributes, operations.
File Organization Sequential, Direct, Indexed.
File Directories Single, two-level, tree, graph.
File Sharing Concurrency, locks, ACLs.
Implementation FCB, disk layout, free space
Issues management.
Protection &
ACLs, encryption, UNIX permissions.
Security
UNIT = 1
Definition:
An Operating System (OS) is system software that acts as an
intermediary between users and computer hardware.
Functions:
1. Process Management
2. Memory Management
3. File System Management
4. Device Management
5. Security and Protection
6. Networking
7. Command Interpretation
Type Description
Jobs with similar needs are grouped; no
Batch OS
user interaction during execution.
65
Type Description
User interacts directly (e.g., command-
Interactive OS
line, GUI).
CPU time is divided among users (e.g.,
Time Sharing OS
UNIX).
Strict timing constraints; immediate
Real-Time OS
response (e.g., avionics).
Multiprocessor
More than one CPU; parallel processing.
OS
Multiple users access simultaneously (e.g.,
Multiuser OS
Linux).
Multiprocess OS Multiple processes run concurrently.
Multithreaded
Supports multiple threads within a process.
OS
Layered Structure:
Hierarchical layers (User interface → Kernel → Hardware).
System Components:
✅ Process management
✅ Memory management
✅ File system
✅ I/O system
✅ Protection and security
OS Services:
Program execution, I/O, file management, error detection, etc.
4 Kernel Types
Type Description
Reentrant Supports multiple processes
Kernel executing kernel code
66
Type Description
simultaneously.
Monolithic All OS services are in one large
Kernel block of code (e.g., UNIX).
Microkernel
UNIT = 2
1 Concurrent Processes
2 Classical Problems
✅ Solutions:
4 IPC Models
✅ Shared Memory
✅ Message Passing
67
5 Process Generation
UNIT = 3
1 CPU Scheduling
2 Deadlock
UNIT = 4
1 Memory Management
68
Multiprogramming: Fixed and variable partitions.
Protection Schemes: Bound registers, relocation.
Paging & Segmentation: Memory divided into frames/pages or
segments.
Paged Segmentation: Combines paging and segmentation.
Virtual Memory: Demand paging, page replacement algorithms
(FIFO, LRU, Optimal), thrashing.
Cache Memory: Fast memory, uses locality of reference.
UNIT = 5
1 I/O Management
2 File System
69