0% found this document useful (0 votes)
10 views74 pages

Operating System Study Material Guide

The document provides comprehensive notes on operating systems, detailing various types such as Real-Time, Multiprocessor, and Batch OS, along with their characteristics and functionalities. It also covers command line and GUI-based operating systems, highlighting examples like DOS, UNIX, Windows, Android, and macOS. The material is intended for engineering students and is part of paid study resources from Campusify.

Uploaded by

shreyashzade927
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)
10 views74 pages

Operating System Study Material Guide

The document provides comprehensive notes on operating systems, detailing various types such as Real-Time, Multiprocessor, and Batch OS, along with their characteristics and functionalities. It also covers command line and GUI-based operating systems, highlighting examples like DOS, UNIX, Windows, Android, and macOS. The material is intended for engineering students and is part of paid study resources from Campusify.

Uploaded by

shreyashzade927
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

OPERATING SYSTEM PAID

UNIT 1 NOTES

This Study Material is provided by [Link] ©


Made by Team Campusify
THIS IS THE PAID STUDY MATERIAL BY CAMPUSIFYPLUS!!

� Be Part of Our Community

Campusify Telegram Channel -


Campusify Whatsapp Channel - CLICK TO JOIN

Campusify is building the Biggest Diploma/Engineering Student Community in


Maharashtra. Be part of the movement!

Exclusive Paid Material by Campusify©


UNIT 1: OS SERVICES AND COMPONENTS (14 MARKS)
2 Marks Questions
1. List types of operating system
 Batch OS
 Multiprogramming OS
 Multitasking OS
 Time Sharing OS
 Distributed OS
 Clustered OS
 Real-Time OS
2. What is meant by operating system?
An Operating System (OS) is system software that manages hardware, software resources, and
provides common services for computer programs.
3. State any two features of Linux.
 Open Source: Freely available and modifiable.
 Multiuser: Multiple users can access resources simultaneously.
 Multitasking: Runs multiple programs at once.
 Security: Offers strong permissions and access control.
4. List components of OS
 Process Management
 Main Memory Management
 File Management
 I/O Management
 Secondary Storage Management
5. List every types of command line based OS
 DOS
 UNIX
 Linux (CLI Mode)
 BSD
6. What is the purpose of system calls / what is meant by system calls?
System calls provide the interface between a user-level process and the operating system, allowing
programs to request services like file handling, process control, etc.

Exclusive Paid Material by Campusify©


4 Marks Questions
1. Explain types of operating system [IMP - Real Time, Multiprocessor, Multitasking, Time
sharing, Multiprogramming, Batch OS].

Real-Time Operating System(RTOS)

A Real-Time Operating System (RTOS) is an operating system designed to handle tasks with strict
timing constraints, where the correctness depends not only on the logical result but also on when that
result is delivered.
Key Characteristics

1. Deterministic timing - RTOSes provide predictable response times, ensuring tasks complete within
specified deadlines. This differs from general-purpose operating systems that optimize for overall
throughput rather than timing guarantees.

2. Priority-based scheduling - Tasks are assigned priorities, and the scheduler ensures higher-priority
tasks preempt lower-priority ones immediately when needed. Common algorithms include Rate
Monotonic Scheduling (RMS) and Earliest Deadline First (EDF).

3. Minimal interrupt latency - The time between an interrupt occurring and the system responding is
kept as low and predictable as possible, often in microseconds.
Types of Real-Time Systems
Hard real-time - Missing a deadline is catastrophic and could cause system failure. Examples include
airbag controllers, pacemakers, and nuclear reactor controls.
Soft real-time - Missing occasional deadlines is undesirable but not catastrophic. Examples include
video streaming, audio processing, and telecommunications.
Firm real-time - Missing deadlines makes the result useless, but doesn't cause system failure.
Examples include live video conferencing where late frames are discarded.
Common RTOS Examples
Commercial: VxWorks, QNX, ThreadX, INTEGRITY, RTX Open source: FreeRTOS, RT-Linux,
RTEMS, Zephyr Academic/Research: MINIX (real-time variant), L4 microkernel family
Applications
RTOSes are essential in embedded systems, industrial automation, automotive electronics, medical
devices, aerospace systems, robotics, and telecommunications equipment where timing predictability
is critical for safety or performance.
The main trade-off is that RTOSes often sacrifice overall system throughput and feature richness to
achieve timing predictability, making them specialized tools for specific applications rather than
general-purpose computing platforms.

Exclusive Paid Material by Campusify©


Multiprocessor Operating System

A Multiprocessor Operating System is designed to manage and coordinate multiple processors (CPUs)
within a single computer system, enabling parallel execution of tasks and efficient resource sharing
across processors.

System Architectures

Symmetric Multiprocessing (SMP) - All processors are identical and share the same memory and I/O
resources. Each processor can execute any task, including operating system functions. This is the most
common architecture in modern multi-core systems.

Asymmetric Multiprocessing (AMP) - Processors have different roles, with one master processor
handling OS functions and scheduling while slave processors execute assigned tasks. Less common in
modern systems but still used in specialized applications.

Non-Uniform Memory Access (NUMA) - Processors have faster access to local memory than remote
memory, requiring the OS to consider memory locality when scheduling tasks and allocating
resources.

Key Challenges and Solutions

Process Synchronization - Multiple processors accessing shared resources simultaneously can cause
race conditions. The OS provides synchronization primitives like mutexes, semaphores, and atomic
operations to coordinate access.

Load Balancing - The OS must distribute tasks evenly across processors to prevent some from being
idle while others are overloaded. This involves sophisticated scheduling algorithms that consider
processor affinity and workload characteristics.

Cache Coherency - When multiple processors cache the same data, the OS must ensure consistency.
Hardware cache coherency protocols (like MESI) work with OS memory management to maintain
data integrity.

Deadlock Prevention - With multiple processors competing for resources, the OS must implement
strategies to detect, prevent, or resolve deadlocks through careful resource ordering and timeout
mechanisms.

Exclusive Paid Material by Campusify©


Multitasking Operating System

A Multitasking Operating System allows multiple tasks or processes to run concurrently on a single
processor or multiple processors, creating the illusion that all tasks are executing simultaneously even when
they're actually sharing CPU time.

Types of Multitasking

Preemptive Multitasking - The operating system controls task switching and can interrupt a running
task at any time to give CPU time to another task. This prevents any single task from monopolizing
the processor. Modern operating systems like Windows, Linux, and macOS use this approach.
Cooperative Multitasking - Tasks voluntarily yield control to other tasks. A misbehaving task can
hang the entire system by not yielding control. Early versions of Windows (3.1) and classic Mac OS
used this model.
Time-Sharing - CPU time is divided into small time slices (typically milliseconds), and each task gets
a turn to execute. When a time slice expires, the OS switches to the next task in the queue.

Key Components

Process Scheduler - Determines which task runs next based on scheduling algorithms like Round
Robin, Priority-based, Shortest Job First, or Multilevel Queue scheduling. The scheduler must balance
fairness, responsiveness, and system throughput.
Context Switching - The mechanism for saving the current state of one task (registers, program
counter, stack pointer) and loading the state of another task. This overhead must be minimized for
efficient multitasking.
Memory Management - Each task needs its own memory space, protected from other tasks. Virtual
memory systems provide isolation and allow tasks to have larger address spaces than physical
memory.
Inter-Process Communication (IPC) - Tasks often need to communicate and share data. The OS
provides mechanisms like pipes, message queues, shared memory, and semaphores for safe
communication.

Advantages
Improved CPU Utilization - While one task waits for I/O operations, other tasks can use the CPU,
dramatically improving overall system efficiency.

Enhanced User Experience - Users can run multiple applications simultaneously, such as browsing the
web while playing music and editing documents.

Better Resource Sharing - Multiple tasks can share system resources like printers, network
connections, and storage devices through OS-mediated access.

Fault Isolation - If one task crashes, other tasks can continue running unaffected (in properly designed
systems with memory protection).

Exclusive Paid Material by Campusify©


Time Sharing Operating System

Time sharing operating systems are designed to allow multiple users to access a computer system
simultaneously by rapidly switching the CPU between different user processes. Here's how they work
and their key characteristics:

Core Principles

Multitasking and Multiprogramming - The OS keeps multiple programs in memory simultaneously and
switches between them so quickly that users experience seemingly concurrent execution. Each process
gets small time slices (typically 10-100 milliseconds) before the CPU switches to the next process.

Interactive Response - Unlike batch processing systems, time sharing OS provides immediate feedback
to users through terminals or workstations, making the computer feel responsive even when serving
many users.

Key Components

Scheduler - The heart of the system that determines which process runs next. Common scheduling
algorithms include round-robin (each process gets equal time slices), priority-based scheduling, and
multilevel feedback queues that adjust priorities based on process behavior.

Memory Management - Since multiple programs must coexist in memory, the OS uses techniques like
virtual memory, paging, and segmentation to efficiently allocate and protect memory spaces for different
users.

Process Management - The OS maintains process control blocks for each running program, tracking
their state, register contents, and memory allocation so it can seamlessly switch between them.

Exclusive Paid Material by Campusify©


Multiprogramming Operating System

Multiprogramming operating systems allow multiple programs to reside in memory simultaneously and
share the CPU, but differ from time sharing systems in their approach and goals. Here's a comprehensive
overview:

Core Concept

Memory Utilization - The primary goal is to keep the CPU busy by having multiple programs loaded in
memory at once. When one program performs I/O operations or waits for resources, the CPU can switch
to executing another program instead of sitting idle.

Non-interactive Processing - Unlike time sharing systems that focus on user interaction,
multiprogramming systems traditionally emphasize throughput and efficient resource utilization, often
processing batch jobs without direct user intervention.

How It Works

Job Scheduling - The OS maintains a job queue of programs waiting to execute. When the system starts,
it loads several programs into different areas of memory simultaneously.

CPU Switching - When the currently executing program encounters an I/O operation, system call, or
other blocking event, the OS immediately switches the CPU to another ready program. This eliminates
the idle time that would occur in single-program systems.

Memory Partitioning - Memory is divided into fixed or variable partitions to hold multiple programs.
Each partition is protected from others to prevent interference.

In a Multiprogramming OS, multiple programs are loaded into memory at the same time. The
CPU switches from one job to another to improve CPU utilization. When one program waits for I/O,
another is given the CPU.
Key Features:
 Better CPU usage
 No direct user interaction
 Mostly used in batch systems
Examples:
 Early IBM Mainframes

Exclusive Paid Material by Campusify©


Batch Operating System

Batch operating systems were among the earliest computer operating systems, designed to process jobs
sequentially without user interaction during execution. They emerged in the 1950s and 1960s to improve
the efficiency of early mainframe computers.
Core Characteristics

Sequential Job Processing - Jobs are collected together into batches and processed one after another in a
predetermined sequence. Once a batch begins execution, it runs to completion without interruption or user
intervention.
Non-interactive Operation - Users cannot interact with their programs while they're running. Instead, they
submit jobs with all necessary instructions, data, and parameters, then wait for the complete results.
Operator-mediated Execution - Computer operators collect jobs from users, organize them into batches,
load them onto the system, and distribute results back to users after processing completes.

How Batch Systems Work

Job Submission - Users prepare their programs and data on punch cards, magnetic tape, or other input
media, along with job control language (JCL) instructions that specify resource requirements and
processing parameters.

Batch Formation - Operators group similar jobs together to maximize efficiency. For example, all
FORTRAN compilation jobs might be batched together, followed by all COBOL jobs.

Automatic Job Sequencing - The OS automatically loads and executes each job in the batch sequence.
When one job finishes, the system immediately begins the next job without manual intervention.

Resource Management - The system allocates memory, I/O devices, and other resources to each job as
needed, then releases them when the job completes.

Advantages

High Throughput - By eliminating setup time between jobs and running similar jobs consecutively, batch
systems achieve high overall system utilization and job throughput.

Cost Effectiveness - Expensive mainframe time is used efficiently since the CPU rarely sits idle between
jobs, making computing more economical for organizations.

Exclusive Paid Material by Campusify©


[Link] Command line based operating systems with their commands: DOS, UNIX
Command Line Based Operating Systems
These OSes allow users to interact with the system by typing text commands into a command-line
interface (CLI) instead of using graphical elements like buttons or windows. They are powerful and
lightweight, but require memorization of commands.

 DOS:
o mkdir folder: Create folder
o dir: List files
o cls: Clear screen
 UNIX:
o $ mkdir OSY: Create folder
o $ cd OSY, $ cat>file: Create file
o $ ls: List files
o $ clear: Clear screen

[Link] GUI based operating systems: Windows, Android, macOS


GUI operating systems represent a fundamental shift from command line
interfaces to visual, intuitive interaction methods. They translate complex
system operations into recognizable visual metaphors like folders, files, trash
cans, and desktops that mirror real-world objects.

Windows Operating System


Architecture and Development
Microsoft Windows evolved from a graphical shell running on MS-DOS to a fully independent operating
system. The modern Windows architecture uses a hybrid kernel design that combines microkernel and
monolithic kernel approaches, providing both performance and modularity.
Key Features and Capabilities
Multitasking and Memory Management - Windows uses preemptive multitasking with priority-based
scheduling, allowing multiple applications to run simultaneously. Virtual memory management with
paging enables programs to use more memory than physically available.
File System Technology - NTFS (New Technology File System) provides advanced features like file
compression, encryption, disk quotas, and journaling for crash recovery. It supports large files and volumes
with sophisticated access control.
Application Compatibility - Windows maintains extensive backward compatibility through various
compatibility layers and emulation technologies, allowing older applications to run on newer OS versions.
Security Architecture - User Account Control (UAC), Windows Defender integration, and BitLocker
encryption provide multiple layers of security. The system implements access control lists (ACLs) for fine-
grained permission management.

Exclusive Paid Material by Campusify©


Android Operating System
Architecture and Foundation
Android is built on a modified Linux kernel, creating a unique mobile operating system architecture. The
system uses a Java-based application framework running on the Android Runtime (ART), which replaced
the earlier Dalvik virtual machine.
Layered Architecture consists of the Linux kernel at the bottom, followed by the Hardware Abstraction
Layer (HAL), native libraries and Android Runtime, the Application Framework layer, and finally the
Applications layer where user apps reside.
Process Management - Each Android application runs in its own process with a unique user ID, providing
security isolation. The system uses a unique application lifecycle with states like created, started, resumed,
paused, stopped, and destroyed.
Mobile-Specific Features
Touch Interface Design - Android pioneered many touch interface concepts including multi-touch
gestures, long-press context menus, swipe navigation, and pinch-to-zoom functionality that became
standard across mobile platforms.
Notification System - The pull-down notification panel provides centralized access to alerts, quick
settings, and ongoing operations. Rich notifications can include interactive elements, images, and action
buttons.
Intent System - This unique Android feature allows applications to communicate and share functionality
through a messaging system, enabling deep integration between apps and system services.

macOS Operating System


UNIX Foundation and Architecture
macOS is built on Darwin, an open-source UNIX-based operating system that combines the Mach
microkernel with BSD (Berkeley Software Distribution) components. This foundation provides stability,
security, and POSIX compliance.
Hybrid Kernel Design - The Mach microkernel handles low-level operations like memory management
and inter-process communication, while BSD components provide higher-level services like networking,
file systems, and process management.
Objective-C and Swift Integration - The system frameworks are primarily written in Objective-C, with
increasing Swift adoption. This provides dynamic runtime capabilities and elegant object-oriented
programming models.
Aqua Interface and Design Philosophy
Design Principles - macOS emphasizes visual metaphors, consistent behavior across applications, and
elegant animations. The Aqua interface introduced concepts like the Dock, translucent elements, and
smooth transitions that influenced GUI design industry-wide.
Window Management - Features like Exposé (now Mission Control), Spaces for virtual desktops, and
automatic window management provide sophisticated multitasking capabilities. The system emphasizes
full-screen applications and gesture-based navigation.
Typography and Graphics - Core Text and Core Graphics frameworks provide advanced text rendering
and 2D graphics capabilities. The system has historically led in font rendering quality and color
management

Exclusive Paid Material by Campusify©


[Link] Types of System Calls and give Examples with Functions.
1. Process Control

What it does: Creates, stops, and manages running programs.

Common examples:

 fork() - Makes a copy of the current program to create a new process

 exec() - Replaces the current program with a different one

 exit() - Ends a process

 wait() - Makes a parent process wait for its child to finish

2. File Management

What it does: Handles file operations like creating, reading, writing, and deleting files.

Common examples:

 open() - Opens a file for use

 read() - Reads data from a file

 write() - Writes data to a file

 close() - Closes a file when done

 create() - Creates a new file

 delete() - Removes a file

3. Device Management

What it does: Controls hardware devices like printers, keyboards, and storage devices.

Common examples:

 ioctl() - Sends special commands to devices

 read() - Gets data from devices

 write() - Sends data to devices

 Device drivers use these to communicate with hardware

4. Information Maintenance

What it does: Gets or changes system information and settings.

Common examples:

 gettimeofday() - Gets the current date and time

 uname() - Gets system information like OS name and version

 getpid() - Gets the process ID number

 setuid() - Changes user permissions

Exclusive Paid Material by Campusify©


5. Communication

What it does: Allows different programs to talk to each other and share data.

Common examples:

 pipe() - Creates a communication channel between processes

 shmget() - Creates shared memory that multiple programs can use

 send() - Sends messages over network

 recv() - Receives messages from network

 Message queues for organized communication

Key Point: System calls are like a bridge between user programs and the operating system - they
let programs ask the OS to do things they can't do themselves, like accessing hardware or
managing files.

Exclusive Paid Material by Campusify©


5. Execution of system call with diagram.

System Call Execution


A system call is the mechanism used by a user-level process to request a service from the operating
system kernel.
It acts as an interface between a running program and the OS, allowing access to hardware-level
functions like:
 File operations (e.g., read(), write())
 Process control (fork(), exec())
 Memory allocation
 Device handling
When a program makes a system call:
1. It switches from user mode to kernel mode.
2. The OS performs the required operation.
3. Control is returned back to the user program.

6 Marks Questions
1. List and explain Six Services of OS.

1. User Interface
The User Interface (UI) is the part of the OS that allows interaction between the user and the
computer hardware.
Types:
 Command Line Interface (CLI): Users type text commands (e.g., DOS, UNIX).
 Graphical User Interface (GUI): Users interact via windows, icons, menus, and pointers
(e.g., Windows, macOS, Android).
Purpose:
 Provides an accessible way for users to operate the system.
 Allows execution of programs, file management, system configuration, etc.

Exclusive Paid Material by Campusify©


2. Program Execution
The OS provides a stable environment where user applications can be loaded and executed.

Functions:
 Loads programs from storage into memory.
 Allocates CPU and resources.
 Manages execution, including starting and stopping.
 Handles multitasking and context switching.
Example:
When you open MS Word or a browser, the OS loads the application into memory and schedules it for
execution.

3. I/O Operations
The OS manages input/output operations between the CPU, memory, and external devices such as
keyboard, mouse, disk, printer, etc.
Functions:
 Provides standardized I/O interfaces so user programs don't access hardware directly.
 Handles buffering, caching, and spooling.
 Manages device drivers for communication with hardware.
Example:
Reading a file from disk or printing a document goes through the I/O management layer of the OS.

4. File System Manipulation


The OS provides access and control over data stored in files and directories.
Functions:
 Allows users to create, delete, read, write, rename files.
 Organizes files into directories or folders.
 Manages permissions and access control.
 Maps logical file structure to physical disk locations.
Example:
Using Windows Explorer or the ls command in Linux to navigate files is part of this service.

5. Communication
OS supports inter-process communication (IPC) to allow data exchange between processes.
Methods:
 Message Passing: Data is exchanged in messages (e.g., pipes, sockets).

Exclusive Paid Material by Campusify©


 Shared Memory: Processes communicate through a shared memory segment.
Purpose:
 Coordination between processes.
 Used in client-server systems, networking, parallel processing, etc.
Example:
Two apps communicating in the background (e.g., a browser plugin updating a browser window) use
IPC.

6. Error Detection
The OS continuously monitors the system for potential errors and takes corrective actions to ensure
stability and reliability.
Functions:
 Detects hardware failures, illegal memory access, and software bugs.
 Logs errors and alerts the user or administrator.
 May attempt automatic recovery or shut down affected programs.
Example:
If a program crashes or a USB device malfunctions, the OS detects and handles the error gracefully.

Exclusive Paid Material by Campusify©


2. Explain Types of OS Tools.
1. Device Management
The Device Management tool is responsible for managing all hardware devices connected to the
computer, such as keyboards, printers, hard disks, scanners, etc.
Functions:
 Device Drivers: The OS uses device drivers to communicate with hardware.
 Buffering and Caching: Temporarily stores data to manage speed differences between
devices and CPU.
 Spooling: Manages data transfer when devices are busy (e.g., printing multiple files).
 Access Control: Ensures correct and safe access to devices.
Example:
When you connect a USB drive, the OS recognizes it, loads the correct driver, and allows file
operations through device management.

2. Task Scheduler
The Task Scheduler is an essential component of the OS that determines which process should run at
any given time.
Functions:
 CPU Scheduling: Allocates CPU time to processes based on algorithms like FCFS, Round
Robin, Priority.
 Multitasking Support: Helps in running multiple processes efficiently.
 Priority Management: Gives preference to high-priority tasks or real-time processes.
 Automation: Can run specific tasks at scheduled times (e.g., backup, virus scans).
Example:
In Windows, the Task Scheduler utility lets users schedule tasks like running antivirus scans at night
automatically.

3. Performance Monitor
The Performance Monitor tool keeps track of the overall system performance including CPU,
memory, disk, and network usage.
Functions:
 Real-time Monitoring: Displays live usage statistics of system resources.
 Logging and Alerts: Keeps logs of usage history and alerts if resource usage exceeds limits.
 Helps in Troubleshooting: Identifies which processes or hardware are causing system
slowdowns.

Exclusive Paid Material by Campusify©


 Resource Optimization: Aids in system tuning for better performance.
Example:
Windows Task Manager or Linux top and htop commands are performance monitoring tools.

4. System Security
System Security tools ensure that the system is protected from unauthorized access, data breaches,
and malware.
Functions:
 User Authentication: Verifies the identity of users via passwords, biometrics, etc.
 Access Control: Grants or denies access to system files, programs, and devices.
 Encryption: Secures sensitive data from being accessed or modified.
 Firewall and Antivirus: Blocks suspicious activities and scans for malware.
Example:
Windows Defender, Linux user/group permission system (chmod, chown), and firewalls are part of
OS security.

5. User Management
The User Management tool is used to create, modify, and manage user accounts and their access
rights.
Functions:
 User Account Creation/Deletion: Admins can add or remove users.
 Group Management: Users can be grouped for easier permission assignment.
 Role Assignment: Defines what operations each user can perform.
 Login Tracking: Keeps record of login attempts, session duration, etc.
Example:
In Linux, commands like adduser, usermod, passwd handle user management; in Windows, the "User
Accounts" panel or net user command does similar tasks.

Exclusive Paid Material by Campusify©


3. Explain following operating system components with its activities:
List of system Components:
Process Management
Main Memory Management
File Management
I/O System Management
Secondary Storage Management

1. Process Management:

A program is a set of instructions. When CPU is allocated to a program, it can start its execution. A
program in execution is a process. A word processing program run by a user on a PC is a process.
A process needs various system resources including CPU time, memory, files and I/O devices to
complete the job execution. These resources can be given to the process when it is created or
allocated to it while it is running. The operating system responsible for the following activities in
connection with process management:
• Creation and deletion of user and system processes.
• Suspension and resumption of processes.
• A mechanism for process synchronization.
• A mechanism for process communication.
• A mechanism for deadlock handling.

2. Main-Memory Management

Main memory is a large array of words or bytes, ranging in size from hundreds of thousands to
billions. Each word or byte has its own address. Main memory is a repository of quickly accessible
data shared by the CPU and I/O devices. The central processor reads instructions from main
memory during the instruction fetch cycle and both reads and writes data from main memory
during the data fetch cycle. The main memory is generally the only large storage device that the
CPU is able to address and access directly. The operating system responsible for the following
activities in connection with main memory s management:
• Keeping track of which parts of memory are currently being used and by whom.
• Deciding which processes (or parts thereof) and data to move into and out of memory.
• Allocating and deallocating memory space as needed.

3. File Management

A file is a collected of related information defined by its creator. Computers can store files on the disk
(secondary storage), which provide long term storage. Some examples of storage media are magnetic
tape, magnetic disk and optical disk. Each of these media has its own properties like speed, capacity,
and data transfer rate and access methods. A file system normally organized into directories to ease
their use. These directories may contain files and other directions.
The operating system responsible for the following activities in connection with file management:
• The creation and deletion of files.
• The creation and deletion of directions.
• The support of primitives for manipulating files and directions.
• The mapping of files onto secondary storage.
• The backup of files on stable storage media.

Exclusive Paid Material by Campusify©


4. I/O device Management

Input / Output device management provides an environment for the better interaction between system
and the I/O devices (such as printers, scanners, tape drives etc.). To interact with I/O devices in an
effective manner, the operating system uses some special programs known as device driver. The
device drivers take the data that operating system has defined as a file and then translate them into
streams of bits or a series of laser pulses (in regard with laser printer). The I/O subsystem consists of
several components:

• A memory management component that includes buffering, caching, spooling


• A general device driver interface
• Drivers for specific hardware devices

5. Secondary-Storage Management

The computer system provides secondary storage to back up main memory. Secondary storage is
required because main memory is too small to accommodate all data and programs, and the data that
it holds is lost when power is lost. Most of the programs including compilers, assemblers, word
processors, editors, and formatters are stored on a disk until loaded into memory. Secondary storage
consists of tapes drives, disk drives, and other media. The operating system is responsible for the
following activities in connection with disk management:
• Free space management
• Storage allocation
• Disk scheduling.

4. Write Two Uses of the Following OS Tools


i) Security Policy
The Security Policy tool in an operating system ensures that the system remains protected from
unauthorized access, malware, and accidental misuse.
1. Controls Access Through Authentication
 The OS requires users to log in using credentials like usernames, passwords, or biometric
verification.
 This authentication ensures that only authorized users can access the system, preventing
intrusion or data theft.
2. Protects System Resources with Permissions
 Every file, folder, or process in the OS has permissions (read, write, execute) associated with
it.
 The security policy enforces user-based or role-based access control, ensuring that users
can only access what they are allowed to.
 Prevents malicious programs or users from modifying system-critical files.

Exclusive Paid Material by Campusify©


ii) User Management
The User Management tool helps system administrators manage multiple users on the same system
efficiently.
1. Manages User Accounts and Groups
 Allows creation, deletion, and modification of user accounts.
 Supports grouping of users based on their roles (e.g., Admins, Students, Guests).
 Helps in applying group-based policies easily across similar users.
2. Assigns Roles and Permissions
 Provides options to assign specific access levels or roles to users.
 Enables fine-grained control like allowing certain users to install apps, while restricting others
to only use them.
 Critical in multi-user environments like colleges, offices, and servers.
iii) Task Scheduler
The Task Scheduler is a tool used to run tasks automatically at specified times or intervals without
manual intervention.
1. Automates Recurring Tasks
 Users or admins can schedule repetitive tasks like daily backups, disk cleanup, or virus
scans.
 Reduces manual effort and ensures tasks are never forgotten.
2. Manages CPU Time for Multitasking
 Divides CPU time between active tasks based on scheduling algorithms.
 Ensures smooth system performance by allocating time slices even to background tasks.
 Prevents any single process from monopolizing the CPU.

Exclusive Paid Material by Campusify©


OPERATING SYSTEM PAID
UNIT 2 NOTES

This Study Material is provided by [Link] ©


Made by Team Campusify
THIS IS THE PAID STUDY MATERIAL BY CAMPUSIFYPLUS!!

� Be Part of Our Community

Campusify Telegram Channel -


Campusify Whatsapp Channel - CLICK TO JOIN

Campusify is building the Biggest Diploma/Engineering Student Community in


Maharashtra. Be part of the movement!

Exclusive Paid Material by Campusify©


UNIT 2: PROCESS MANAGEMENT (14 MARKS)

2 Marks Questions
1. Define Process, PCB.
Process:- A process is a program in execution. Process is also called as job, task or unit of
work.
PCB:- Process Control Block is a data structure that contains information of the process
related to it. The process control block is also known as a task control block, entry of the
process table, etc

2. Type of inter process communication (IPC)


There are two models of IPC
1. Shared memory
2. Message Passing

3. Thread vs Multithreading

4 Marks Questions
1. Draw process state diagram and describe each state.
Different process states are as follows:
1. New
2. Ready
3. Running
4. Waiting
5. Terminated

Exclusive Paid Material by Campusify©


1 New: When a process enters into the system, it is in new state. In this state a process
is created. In new state the process is in job pool.

1. Ready: When the process is loaded into the main memory, it is ready for execution. In
this state the process is waiting for processor allocation.

2. Running: When CPU is available, system selects one process from main memory and
executes all the instructions from that process. So, when a process is in execution, it is
in running state. In single user system, only one process can be in the running state. In
multiuser system, there can be multiple processes which are in the running state.

3. Waiting State: When a process is in execution, it may request for I/O resources. If the
resource is not available, process goes into the waiting state. When the resource is
available, the process goes back to ready state.

4. Terminated State: When the process completes its execution, it goes into the
terminated state. In this state the memory occupied by the process is released.

3. Explain Process Control Block (PCB) with suitable diagram


Each process is represented as a process control block (PCB) in the operating system. It
contains information associated with specific process.
1. Process State: It indicates current state of a process. Process state can be new, ready,
running, waiting and terminated.
2. Process number: Each process is associated with a unique number which is known
process identification number.
3. Program Counter: It indicates the address of the next instruction to be executed for the
process.
4. CPU Registers: The registers vary in number and type depending on the computer
architecture. Register includes accumulators, index registers, stack pointers and
general purpose registers plus any condition code information.
5. Memory Management Information: It includes information such as value of base and
limit registers, page tables, segment tables, depending on the memory system used by
OS.

Exclusive Paid Material by Campusify©


6. Accounting Information: This information includes the amount of CPU used, time
limits, account holders, job or process number and so on. It also includes information
about listed I/O devices allocated to the process such as list of open files.
Each PCB gives information about a particular process for which it is Designed.

4. With suitable diagram, Describe use of Scheduling Queues in Process Scheduling.


Scheduling Queues in Process Scheduling
Process scheduling is a crucial aspect of operating system design, managing the allocation
of system resources to processes. Scheduling queues play a vital role in this process.

Types of Scheduling Queues


1. Job Queue: Holds all processes in the system.
2. Ready Queue: Stores processes that are ready to execute and waiting for CPU
allocation.
3. Device Queue: Manages processes waiting for specific I/O devices.

Exclusive Paid Material by Campusify©


Process Flow
1. Process Arrival: A new process arrives and is placed in the Job Queue.
2. Admission: The process is admitted to the system and moved to the Ready Queue.
3. CPU Allocation: The process is allocated the

5. Explain context switch with diagram


Context Switch
A context switch is the process of switching the CPU's context from one process to
another. This involves saving the current state of the process being switched out and
restoring the state of the process being switched in.

1. Save Current State: The operating system saves the current state (context) of the
process being switched out, including registers, program counter, and memory pointers.
2. Restore New State: The operating system restores the saved state of the process being
switched in.

Exclusive Paid Material by Campusify©


PCB stands for Process Control Block, which stores information about each process.

Context Switch Triggers


1. Time Slicing: When a process's time slice expires.
2. I/O Operation: When a process performs I/O operations.
3. Priority Scheduling: When a higher-priority process arrives.

Overhead
Context switching incurs overhead due to:

1. Saving and restoring process states.


2. Updating process control blocks.

Efficient context switching is crucial for system performance.

Exclusive Paid Material by Campusify©


6. Describe use of top, ps, kill, wait, sleep, exit, nice commands with suitable example
and with it’s option. [This Concept called as process commands]
1 ps command: It is used to display the characteristics of a process. This with a user at a
particular terminal.
Syntax: $ ps [options]

4. kill command : The kill command sends a signal to a process, instructing it to


terminate or stop its execution , The kill command can send various signals to a
process, such as SIGTERM (termination), SIGKILL (forced termination), or SIGHUP
(hang up).
Syntax: $ kill pid

5. sleep command : The sleep command suspends the execution of a process or


command for a specified duration.
Syntax: $sleep NUMBER[SUFFIX]…

6. exit command : 1. Terminate a session: Exit the current command-line interface or


terminal session.
2. Close a shell: Close the current shell or command prompt.
Syntax: $ exit [exit_status]
exit_status (optional): specifies the exit status code (0 for success, non-zero for error).
7. nice command : 1. Set priority: Adjust the scheduling priority of a process.
2. Run with lower priority: Run a command or process with a lower priority, allowing
other processes to take precedence.
Syntax: $ nice [-n priority] command [arguments]

-n priority: specifies the niceness value (range: -20 to 19)


-Lower values (e.g., -20) increase priority
-Higher values (e.g., 19) decrease priority
-command: the command to run with adjusted priority
-arguments: optional arguments for the command

8. wait command : 1. Pause execution: Suspend the execution of a script or command


until a specific process or job completes.
2. Wait for background processes: Wait for background processes to finish before
continuing execution.
Syntax: $ wait [job_id or process_id]
- job_id: specifies the job ID of a background process
- process_id: specifies the process ID of a process to wait for

9. top command : 1. Display system processes: Show a real-time list of running


processes, including their resource usage.
2. Monitor system performance: Provide information on CPU, memory, and process
utilization.
Syntax: $ top [options]

Exclusive Paid Material by Campusify©


Some common options include:

- -d : Specify the delay between updates (e.g., -d 5 for 5-second intervals)


- -n : Specify the number of iterations (e.g., -n 1 for a single update)
- -p : Monitor specific processes

7. Explain Thread with it’s any four benefits and it’s types
A thread is a lightweight process that runs concurrently with other threads within the same
process. Threads share the same memory space and resources, allowing for efficient
communication and data exchange.
A thread is a separate flow of execution within a process. It's a lightweight process that
shares the same memory space and resources as other threads in the same process.
Think of a thread like a mini-program that runs concurrently with other threads, allowing
for:
 Concurrent execution
 Improved responsiveness
 Efficient resource usage
Benefits of Threads
 Improved Responsiveness: Threads enable concurrent execution, allowing a program
to respond to user input and events while performing time-consuming tasks in the
background.
 Increased Throughput: Multithreading can improve system utilization and
throughput by leveraging multiple CPU cores and executing tasks in
parallel.
 Efficient Resource Usage: Threads share the same memory space, reducing the
overhead of creating and managing separate processes.
 Simplified Programming: Threads can simplify programming by allowing
developers to write concurrent code that's easier to understand and
maintain.

TYPES OF THREADS
1. User-Level Threads:
In a user thread, all of the work of thread management is done by the application and the
kernel is not aware of the existence of threads.
The thread library contains code for creating and destroying threads, for passing message and
data between threads, for scheduling thread execution and for saving and restoring thread
contexts.
The application begins with a single thread and begins running in that thread. User level
threads are generally fast to create and manage.

Exclusive Paid Material by Campusify©


2. Kernel Level Threads
In Kernel level thread, thread management done by the Kernel. There is no thread
management code in the application area.
Kernel threads are supported directly by the operating system. Any application can be
programmed to be multithreaded.
All of the threads within an application are supported within a single process. The Kernel
maintains context information for the process as a whole and for individual threads within
the process.
Scheduling by the Kernel is done on a thread basis. The Kernel performs thread creation,
scheduling and management in Kernel space. Kernel threads are generally slower to
create and manage than the user threads.

6. Explain critical section problem with example.


The critical section problem occurs when multiple processes or threads access shared
resources or data simultaneously, potentially leading to data inconsistency or race conditions.
Example:
Consider two processes, P1 and P2, accessing a shared variable x = 10:
1. P1: x = x + 1 (read x, increment, write x)
2. P2: x = x - 1 (read x, decrement, write x)
If both processes execute simultaneously, the final value of x may be inconsistent due to
interleaved execution:
1. P1 reads x = 10
2. P2 reads x = 10 (before P1 writes)
3. P1 writes x = 11
4. P2 writes x = 9 (overwriting P1's update)
Solution:
To solve this problem, use synchronization mechanisms like:
1. Mutex (locks): Ensure exclusive access to shared resources.
2. Semaphores: Control access to shared resources using signals.
By synchronizing access, we ensure data consistency and prevent race conditions.
Key Points:
1. Critical section: Code accessing shared resources.
2. Mutual exclusion: Ensuring only one process accesses shared resources at a time.
3. Synchronization mechanisms: Mutex, semaphores, etc.

Exclusive Paid Material by Campusify©


6 Marks Questions

1. Explain interprocess communication model (IPC) with it’s types in detail ( Shared
memory, Message Passing )
Inter-process communication: Cooperating processes require an Interprocess communication
(IPC) mechanism that will allow them to exchange data and information. There are two
models of IPC
1. Shared memory
1. In this, all processes who want to communicate with other processes can access a region of
the memory residing in an address space of a process creating a shared memory segment.
2. All the processes using the shared memory segment should attach to the address space of
the shared memory. All the processes can exchange information by reading and/or writing
data in shared memory segment.
3. The form of data and location are determined by these processes who want to communicate
with each other.
4. These processes are not under the control of the operating system.
5. The processes are also responsible for ensuring that they are not writing to the same
location simultaneously.
6. After establishing shared memory segment, all accesses to the shared memory segment are
treated as routine memory access and without assistance of kernel.

Exclusive Paid Material by Campusify©


2. Message Passing
1. In this model, communication takes place by exchanging messages between cooperating
processes.
2. It allows processes to communicate and synchronize their action without sharing the
same address space.
3. It is particularly useful in a distributed environment when communication process may
reside on a different computer connected by a network.
4. Communication requires sending and receiving messages through the kernel.
5. The processes that want to communicate with each other must have a communication
link between them. Between each pair of processes exactly one communication link.

Exclusive Paid Material by Campusify©


2. Explain multithreading model with there types and advantages. ( One to One, Many
to One, Many to Many )
Many systems provide support for both user and kernel threads, resulting in different
multithreading models. Following are three multithreading model:
1. Many-to-One Model

 The many-to-one model maps many user-level threads to one kernel thread.
 Thread management is done by the thread library in user space, so it is efficient; but
the entire process will block if a thread makes a blocking system call.
 Also, because only one thread can access the kernel at a time, multiple threads are
unable to nm in parallel on multiprocessors.
 Example: Green threads- a thread library available for Solaris

Advantages :
 More concurrency because of multiple threads can run in parallel on multiple CPUs.
 Less complication in the processing.

Disadvantages:
 Thread creation involves light-weight process creation.
 Kernel thread is an overhead.
 Limiting the number of total threads.

Exclusive Paid Material by Campusify©


2. One-to-One Model

 The one-to-one model maps each user thread to a kernel thread.


 It provides more concurrency than the many-to-one model by allowing another
thread to run when a thread makes a blocking system call; it also allows multiple
threads to run in parallel on multiprocessors.
 The only drawback to this model is that creating a user thread requires creating the
corresponding kernel thread.
 Because the overhead of creating kernel threads can burden the performance of an
application, most implementations of this model restrict the number of threads
supported by the system.
 Linux, along with the family of Windows operating systems, implement the one-
to-one model.

Advantages:
 Mainly used in language system, portable libraries.
 One kernel thread controls multiple user thread.

Disadvantages:
 Parallelism is not supported by this model.
 One block can blocks all user threads.

Exclusive Paid Material by Campusify©


3. Many-to-Many Model

 The many-to-many model multiplexes many user-level threads to a smaller or


equal number of kernel threads.
 The number of kernel threads may be specific to either a particular application or
a particular machine (an application may be allocated more kernel threads on a
multiprocessor than on a uniprocessor).
 The one-to-one model allows for greater concurrency, but the developer has to be
careful not to create too many threads within an application (and in some
instances may be limited in the number of threads she can create).
 The many-to-many model suffers from neither of these shortcomings: developers
can create as many user threads as necessary, and the corresponding kernel threads
can run in parallel on a multiprocessor.
 Also, when a thread performs a blocking system call, the kernel can schedule
another thread for execution.

Advantages:

 Many threads can be created as per user’s requirement.


 Multiple kernel or equal to user threads can be created.

Disadvantages:
 True concurrency cannot be achieved.
 Multiple threads of kernel is an overhead for operating system.

Exclusive Paid Material by Campusify©


3. State and describe each types of schedulers.

There are three types of scheduler:

1. Long term scheduler


2. Short term scheduler
3. Medium term scheduler

Long term scheduler:


 It selects programs from job pool and loads them into the main memory. It
controls the degree of multiprogramming.
 The degree of multiprogramming is the number of processes loaded
(existing) into the main memory. System contains I/O bound processes and
CPU bound processes.
 An I/O bound process spends more time for doing I/O operations whereas
CPU bound process spends more time in doing computations with the CPU.
So It is the responsibility of long term scheduler to balance the system by
loading some I/O bound and some CPU bound processed into the main
memory.
 Long term scheduler executes only when a process leaves the system, so it
executes less frequently.
 When long term scheduler selects a process from job pool, the state of
process changes from new to ready state.

Short term scheduler:


 It is also known as CPU scheduler.
 This scheduler selects processes that are ready for execution from the ready
queue and allocates the CPU to the selected process.
 Frequency of execution of short term scheduler is more than other
schedulers.
 When short term scheduler selects a process, the state of process changes
from ready to running state.

Medium term scheduler:


 When a process is in running state, due to some interrupt it is blocked.
 System swaps out blocked process and store it into a blocked and swapped
out process queue.
 When space is available in the main memory, the operating system looks at
the list of swapped out but ready processes.
 The medium term scheduler selects one process from that list and loads it
into the ready queue.
 The job of medium term scheduler is to select a process from swapped out
process queue and to load it into the main memory.
 This scheduler works in close communication with long term scheduler for
loading process into the main memory.

Exclusive Paid Material by Campusify©


4. Difference between user level and kernel level thread

Exclusive Paid Material by Campusify©


OPERATING SYSTEM PAID
UNIT 3 NOTES

This Study Material is provided by [Link] ©


Made by Team Campusify
THIS IS THE PAID STUDY MATERIAL BY CAMPUSIFYPLUS!!

� Be Part of Our Community

Campusify Telegram Channel -


Campusify Whatsapp Channel - CLICK TO JOIN

Campusify is building the Biggest Diploma/Engineering Student Community in


Maharashtra. Be part of the movement!

Exclusive Paid Material by Campusify©


UNIT 3 : CPU SCHEDULING (16 MARKS)
2 marks question
1. Define virtual memory, paging
 Virtual Memory: Virtual memory is a memory management capability of an
operating system (OS) that uses hardware and software to allow a computer to
compensate for physical memory shortages by temporarily transferring data from
RAM to disk storage.
 Paging: Paging is a storage mechanism used to retrieve processes from secondary
storage to main memory in the form of fixed-size blocks called pages.
2. What is scheduling?
 Scheduling is the process by which the operating system decides which process in the
ready queue should be executed next by the CPU. It ensures optimal CPU utilization
and fairness among processes
3. Difference between preemptive and non-preemptive scheduling

4. Explain deadlock
 Deadlock is a situation where a set of processes are blocked because each process is
holding a resource and waiting for another resource held by another process.
5. What is priority scheduling?
 In this scheduling, each process is assigned a priority. The CPU is allocated to the
process with the highest priority. If two processes have the same priority, they are
scheduled according to their arrival time

Exclusive Paid Material by Campusify©


4 MARKS QUESTIONS

1.I/O burst and CPU burst with diagram

CPU burst cycle: It is a time period when process is busy with CPU.
I/O burst cycle: It is a time period when process is busy in working
with I/O resources.
 A process execution consists of a cycle of CPU execution and I/O wait.

 A process starts its execution when CPU is assigned to it, so process execution begins with
a CPU burst cycle.
 This is followed by an I/O burst cycle when a process is busy doing I/O operations.
 A process switch frequently from CPU burst cycle to I/O burst cycle and vice versa.
 The complete execution of a process starts with CPU burst cycle, followed by I/O burst
cycle, then followed by another CPU burst cycle, then followed by another I/O burst cycle
and so on.
 The final CPU burst cycle ends with a system request to terminate execution

Exclusive Paid Material by Campusify©


[Link] scheduling criteria

CPU utilization: In multiprogramming the main objective is to


keep CPU as busy as possible. CPU utilization can range from 0 to
100 percent.

Throughput: It is the number of processes that are completed per


unit time. It is a measure of work done in the system. When CPU is
busy in executing processes, then work is being done in the system.
Throughput depends on the execution time required for any
process. For long processes, throughput can be one process per unit
time whereas for short processes it may be 10 processes per unit
time.

Turnaround time: The time interval from the time of submission


of a process to the time of completion of that process is called as
turnaround time. It is the sum of time period spent waiting to get
into the memory, waiting in the ready queue, executing with the
CPU, and doing I/O operations.

Waiting time: It is the sum of time periods spent in the ready


queue by a process. When a process is selected from job pool, it is
loaded into the main memory (ready queue). A process waits in
ready queue till CPU is allocated to it. Once the CPU is allocated
to the process, it starts its execution and if required request for
resources. When the resources are not available that process goes
into waiting state and when I/O request completes, it goes back to
ready queue. In ready queue again it waits for CPU allocation.

Response time: The time period from the submission of a


request until the first response is produced is called as response
time. It is the time when system responds to the process request
not the completion of a process. In the system, a process can
Produce some output fairly early and can continue computing
new results while previous results are being output to the user.

Exclusive Paid Material by Campusify©


[Link] Concepts : i) What are necessary conditions for deadlock?
ii) Describe Condition for Deadlock Preventions and avoidance.
Deadlock in Operating System
In a multiprogramming environment, several processes may compete for a finite number of
resources. A process requests resources, and if the resources are not available, the process
enters into the waiting state.
Sometimes, a waiting process is never able to change its status because the resources it
requested are held by other waiting processes. This situation is called a deadlock.
When a process requests a resource held by another waiting process, which in turn is waiting
for a resource held by another waiting process, and no single process can proceed, then
deadlock occurs in the system.
Example:
Consider a system with three disk drives and three processes.
 Each process requests one disk drive.
 The system allocates one disk drive to each process.
 Now, no more disk drives are available.
 If each process requests one more disk drive, all processes will move to the waiting
state.
Necessary Conditions for Deadlock:
1. Mutual Exclusion
At least one resource must be held in a non-sharable mode, meaning only one
process can use the resource at a time.
2. Hold and Wait
A process must be holding at least one resource and waiting to acquire additional
resources currently held by other processes.
3. No Preemption
Resources cannot be forcibly taken from a process; they must be released
voluntarily by the process holding them.
4. Circular Wait
A set of processes {P0, P1, ..., Pn} must exist such that:
o P0 is waiting for a resource held by P1,
o P1 is waiting for a resource held by P2,
o ...,
o Pn is waiting for a resource held by P0.
This forms a circular chain of waiting processes, where each is waiting for a resource
held by the next process in the chain.

Exclusive Paid Material by Campusify©


Four Necessary Conditions for Deadlock (Coffman’s conditions):
1. Mutual Exclusion – Only one process can use a resource at a time.
2. Hold and Wait – A process holding one resource can request another.
3. No Preemption – Resources can’t be forcibly taken from a process.
4. Circular Wait – A circular chain of processes exists, each waiting for a resource held by the next

Deadlock Prevention
Deadlock prevention ensures that at least one of the four conditions for deadlock is never allowed.
Techniques:
1. Mutual Exclusion:
o Not possible to eliminate for non-sharable resources like printers.
2. Hold and Wait:
o Require processes to request all resources at once, before execution starts.
o Drawback: Can lead to low resource utilization and starvation.
3. No Preemption:
o If a process is holding resources and requests another unavailable one, it must release all currently
held resources.
o Drawback: Leads to rollback and increased overhead.
4. Circular Wait:
o Impose a global order on resource types and require processes to request resources in an
increasing order of enumeration.
o Effective for static resource allocation systems.

Deadlock Avoidance

Deadlock avoidance allows the system to dynamically examine resource allocation and decide whether it
is safe to proceed.

Conditions:
 The system must have prior knowledge of resource requirements (maximum demand) for each process.

Common Technique:

Banker’s Algorithm:
 Checks whether granting a resource keeps the system in a safe state.
 A state is safe if there exists a sequence of all processes such that each process can complete with
available + allocated resources.

Drawbacks:
 Needs advance knowledge of maximum resources.
 Can be complex and expensive to implement in real time.

Exclusive Paid Material by Campusify©


[Link] steps required for Banker’s algorithm
The Banker’s Algorithm is a deadlock avoidance algorithm that checks if resource
allocation leaves the system in a safe state.
Step-by-Step Procedure:
1. Check Request ≤ Need
o If the requested resources by a process are greater than its declared
maximum need, raise an error (invalid request).
o If Request[i] > Need[i], then the process has exceeded its maximum claim →
Error.
2. Check Request ≤ Available
o If the requested resources are not available, the process must wait.
o If Request[i] > Available, then the resources are not available → Wait.
3. Pretend to Allocate Resources Temporarily
o Assume the system grants the requested resources.
Update the data structures:

Available = Available - Request[i] Allocation[i]


= Allocation[i] + Request[i] Need[i] = Need[i]
- Request[i]
4. Check for System Safety
o Perform the Safety Algorithm to check if the system is in a safe state after
this allocation.
o If a safe sequence exists → the resources are officially allocated.
o If not → rollback the allocation (i.e., restore original state) and make the
process wait.

Exclusive Paid Material by Campusify©


[Link] multilevel queue scheduling with neat diagram.

Multilevel Queue Scheduling is a CPU scheduling algorithm that divides the ready queue
into multiple separate queues, each for a specific type of process. Each queue has its own
scheduling algorithm, and processes are permanently assigned to one queue based on
priority, memory size, process type, etc.
Key Features:
1. Processes are classified into different groups such as:
o System processes
o Interactive processes
o Batch processes
2. Each queue may use a different scheduling algorithm:
o Foreground queue: Round Robin
o Background queue: FCFS (First Come First Serve)
3. No movement between queues (processes stay in their assigned queue permanently).
4. Scheduling between queues can be based on:
o Fixed priority preemptive scheduling (e.g., always serve system queue
before user queue), or
o Time-slice rotation among queues.
Advantages:
 Easy to implement scheduling policies for different process types.
 High-priority tasks are handled quickly.
Disadvantages:
 Starvation of low-priority processes (if high-priority queues are always full).
 No dynamic movement between queues.

Exclusive Paid Material by Campusify©


6 MARKS QUESTIONS

1. Explain types of scheduling in detail ( Preemptive and Non-preemptive )

1. Preemptive Scheduling

Definition:
In preemptive scheduling, the CPU can be taken away from a process that is currently
executing if a higher priority process arrives or the time slice expires (in time-sharing
systems).

Key Features:
 A process can be interrupted in the middle of execution.
 Suitable for real-time and interactive systems.
 More responsive but complex to implement.
Examples:
 Round Robin (RR)
 Shortest Remaining Time First (SRTF / SRTN)
 Priority Scheduling (Preemptive)

Advantages:
 Ensures better responsiveness for time-critical tasks.
 CPU utilization is higher due to better task distribution.
Disadvantages:
 Requires more context switching, leading to overhead.
 Complex to implement and manage

2. Non-Preemptive Scheduling

Definition:
In non-preemptive scheduling, once a process is assigned the CPU, it keeps it until it
completes execution or voluntarily enters the waiting state.

Key Features:

 A running process cannot be interrupted.


 Simpler and easier to implement.
 Suitable for batch systems

Exclusive Paid Material by Campusify©


Examples:

 First Come First Serve (FCFS)


 Shortest Job First (SJF - Non-Preemptive)
 Priority Scheduling (Non-Preemptive)

Advantages:

 Simple and easy to manage.


 No overhead of context switching.

Disadvantages:

 Poor responsiveness.
 A long job can block short, urgent jobs (i.e., leads to starvation).

[Link] types of scheduling algorithms with example ( FCFS, SJF, SRTN, RR )


1. First Come First Serve (FCFS)
FCFS is the simplest scheduling algorithm where the process that arrives first gets executed
first.
It is non-preemptive and uses a queue structure.
Example:
Processes: P1, P2, P3
Arrival Time: 0, 1, 2
Burst Time: 5, 3, 1
Execution Order: P1 → P2 → P3
2. Shortest Job First (SJF)
SJF selects the process with the smallest burst time among the available processes.
It is non-preemptive.
Example:
Processes: P1, P2, P3
Burst Time: 6, 2, 4
Execution Order: P2 → P3 → P1
3. Shortest Remaining Time Next (SRTN or SRTF)
It is the preemptive version of SJF.
CPU is given to the process with the shortest remaining burst time.
If a new process arrives with a shorter burst time than the current running one, CPU is
preempted.

Exclusive Paid Material by Campusify©


Example:
P1 (AT=0, BT=7), P2 (AT=2, BT=4), P3 (AT=4, BT=1)
P3 will preempt the current process because of the shortest remaining time.
4. Round Robin (RR)
In Round Robin, each process is assigned a time quantum (time slice).
Processes are executed in a circular order and preempted after each time slice.
Example:
Time Quantum = 2
Processes: P1 (BT=4), P2 (BT=3), P3 (BT=5)
Execution: P1 → P2 → P3 → P1 → P2 → P3 → P3

Exclusive Paid Material by Campusify©


NUMERICALS
Example
The jobs are scheduled for execution as follows:

i) SJF

ii) FCFS

Also find average waiting time using Gantt chart

1. Non-Preemptive SJF (Shortest Job First)

Gantt Chart:
P1 P2 P4 P5 P3
0 7 11 17 25 35 (note: draw gannt chart in table form)

Process Arrival Burst Completion Turnaround Waiting Time


Time Time Time Time (CT - AT) (TAT - BT)

P1 0 7 7 7-0=7 7-7=0

P2 1 4 11 11 - 1 = 10 10 - 4 = 6

P4 3 6 17 17 - 3 = 14 14 - 6 = 8

P5 4 8 25 25 - 4 = 21 21 - 8 = 13

P3 2 10 35 35 - 2 = 33 33 -10 =
23

Average Turnaround Time = (7 + 10 + 14 + 21 + 33) / 5 = 85 / 5 = 17

Exclusive Paid Material by Campusify©


2. Preemptive SJF (SRTN)
Gantt Chart:
P1 P2 P1 P4 P5 P3
0 1 5 11 17 25 35

Process Arrival Burst Completion Turnaround Waiting


Time Time Time Time Time

P1 0 7 11 11 - 0 = 11 11 - 7 = 4

P2 1 4 5 5-1=4 4-4=0

P4 3 6 17 17 - 3 = 14 14 - 6 = 8

P5 4 8 25 25 - 4 = 21 21 - 8 = 13

P3 2 10 35 35 - 2 = 33 33 -10 = 23

Average Turnaround Time = (11 + 4 + 14 + 21 + 33) / 5 = 83 / 5 = 16.6

3. FCFS (First Come First Serve)


Gantt Chart:
P1 P2 P3 P4 P5
0 7 11 21 27 35
Process Arrival Burst Completion Turnaround Waiting Time
Time Time Time Time

P1 0 7 7 7-0=7 7-7=0

P2 1 4 11 11 - 1 = 10 10 - 4 = 6

P3 2 10 21 21 - 2 = 19 19 -10 = 9

P4 3 6 27 27 - 3 = 24 24 - 6 = 18

P5 4 8 35 35 - 4 = 31 31 - 8 = 23

Exclusive Paid Material by Campusify©


Average Turnaround Time = (7 + 10 + 19 + 24 + 31) / 5 = 91 / 5 = 18.2)

Round Robin Scheduling (Time Quantum = 4)

Gantt Chart (Time Quantum = 4)

| P1 | P2 | P3 | P4 | P5 | P1 | P3 | P4 | P5 | P3 |
0 4 8 12 16 20 23 27 29 33 35

Process Table

Process Arrival Time Burst Time Completion Time Turnaround Time (CT - AT) Waiting Time (TAT - BT)

P1 0 7 23 23 - 0 = 23 23 - 7 = 16

P2 1 4 8 8-1=7 7-4=3

P3 2 10 35 35 - 2 = 33 33 -10 = 23

P4 3 6 29 29 - 3 = 26 26 - 6 = 20

P5 4 8 33 33 - 4 = 29 29 - 8 = 21

Average Calculations

 Average Turnaround Time


= (23 + 7 + 33 + 26 + 29) / 5
= 118 / 5 = 23.6

 Average Waiting Time


= (16 + 3 + 23 + 20 + 21) / 5
= 83 / 5 = 16.6

NOTE:

Turnaround Time (TAT) = Completion Time (CT) - Arrival Time (AT)

Waiting Time (WT) = Turnaround Time (TAT) - Burst Time (BT)

Avg TAT = (Sum of all Turnaround Times) / Number of Processes

= (TAT₁ + TAT₂ + TAT₃ + ... + TATn) / n

Avg WT = (Sum of all Waiting Times) / Number of Processes

Exclusive Paid Material by Campusify©


OPERATING SYSTEM PAID
UNIT 4 NOTES

This Study Material is provided by [Link] ©


Made by Team Campusify
THIS IS THE PAID STUDY MATERIAL BY CAMPUSIFYPLUS!!

� Be Part of Our Community

Campusify Telegram Channel -


Campusify Whatsapp Channel - CLICK TO JOIN

Campusify is building the Biggest Diploma/Engineering Student Community in


Maharashtra. Be part of the movement!

Exclusive Paid Material by Campusify©


UNIT 4: Memory Management (16 MARKS)

2 Marks Questions

1. Define : Swapping, Compaction, Fragmentation, Paging

 Paging : Paging is a storage mechanism used in OS to retrieve processes from secondary


storage to the main memory as pages.

 Segmentation : Segmentation is a memory administration approach used in operating


systems that divides memory into multiple-sized segments

 Fragmentation : When processes are loaded and removed from memory, the free memory
space is broken into little pieces which is known as fragmentation.

 Swapping : Swapping is a memory management technique used by operating systems for


emporarily move a process from main memory (RAM) to secondary storage (hard disk) and
vice versa. Create space in RAM for other processes or system operations.

2. Explain Page fault, Demand Paging, Dynamic Relocation

 Page fault : A page fault is an interrupt that occurs when a process tries to access a page (a
block of memory) that is not currently in physical memory (RAM).
Page Faults Occur because the page is not loaded into RAM or the page was previously
swapped out to disk.

 Demand Paging : Demand paging is a memory management technique where a page is


loaded into physical memory (RAM) only when it's actually needed (on demand). A process
tries to access a page not in RAM , The page is loaded into RAM, and the process continues.

 Dynamic Relocation : Dynamic relocation is a memory management technique that allows


the operating system to:
1. Map virtual addresses: Map virtual addresses used by a process to physical addresses in
RAM.
2. Relocate processes: Move a process to a different location in physical memory during
execution.

Exclusive Paid Material by Campusify©


4 Marks Questions
1. Explain Partitioning and it’s types with diagram [ Variable, Fixed Sized ].
 An important operation of memory management is to bring programs into main
memory for execution by the processor.
 Partitioning is a technique that divides a memory into multiple partitions. These
partitions can be of different size or same size.

Types of partitioning :

1. Fixed partitioning i.e. static partitioning


2. Variable partitioning i.e. dynamic partitioning

1. Fixed partitioning :

 Memory is divided into number of fixed size partitions, which is called as fixed or static
memory partitioning.
 Each partition contains exactly one process.
 The number of programs to be executed depends on number of partitions.
 When the partition is free, a selected process from the input queue is loaded into the
free partition.
 When the process terminates, the partition becomes available for another process .
 The operating system keeps a table indicating parts of memory which are available and
which are occupied.
 Initially, all memory is available for user processes and it is considered as one large
block of available memory, a hole.
 When a process arrives, large enough hole of memory is allocated to the processes.

2. Variable partitioning :

 When a process enters in main memory, it is allocated exact size that is required by
that process.
 So in this method, partitions can vary in size depending on memory space required by
a process entering in main memory.
 Operating system maintains a table indicating which parts of memory are available and
which are occupied.
 When new process arrives and it needs space, system searches for available memory
space in main memory.
 If it is available, then memory is allocated to the process by creating a partition in
memory.

Exclusive Paid Material by Campusify©


2. Explain Partitioning Algorithms with example ( First fit, Best fit, Worst fit ).

1. First Fit : First fit is a memory allocation algorithm used in partitioning,


where the operating system:

1. Searches for free space: Looks for the first available partition that's large
enough to hold the process.
2. Allocates the process: Allocates the process to the first suitable partition.

2. Best Fit : Best fit is a memory allocation algorithm that:

1. Searches for smallest suitable partition: Finds the smallest partition


that's large enough to hold the process.
2. Allocates the process: Allocates the process to the smallest suitable partition.

3. Worst fit : Worst Fit is a memory allocation algorithm that:

1. Searches for largest available partition: Finds the largest partition available.

2. Allocates the process: Allocates the process to the largest partition.

Exclusive Paid Material by Campusify©


3. Explain Non-contiguous Memory Management Techniques: Paging, Segmentation

1. Paging :

 Paging is the process of moving parts of a program, called pages, from secondary
storage (like a hard drive) into the main memory (RAM). The main idea behind
paging is to break a program into smaller fixed-size blocks called pages.
 To keep track of where each page is stored in memory, the operating system uses a
page table. This table shows the connection between the logical page numbers (used
by the program) and the physical page frames (actual locations in RAM).
 The memory management unit uses the page table to convert logical addresses into
physical addresses, so the program can access the correct data in memory.

Important Features of Paging

 Logical to physical address mapping: Paging divides a process's logical address


space into fixed-size pages. Each page maps to a frame in physical memory, enabling
flexible memory management
 Fixed page and frame size: Pages and frames have the same fixed size. This
simplifies memory management and improves system performance.
 Page table entries: Each logical page is represented by a page table entry (PTE). A
PTE stores the corresponding frame number and control bits.
 Number of page table entries: The page table has one entry per logical page. Thus,
its size equals the number of pages in the process's address space.
 Page table stored in main memory: The page table is kept in main memory. This
can add overhead when processes are swapped in or out.

2. Segmentation :

 A process is divided into Segments. The chunks that a program is divided into which are not
necessarily all of the exact sizes are called segments.
 Segmentation gives the user's view of the process which paging does not provide. Here the
user's view is mapped to physical memory.

Exclusive Paid Material by Campusify©


Types of Segmentation in Operating Systems

 Virtual Memory Segmentation: Each process is divided into a number of segments, but the
segmentation is not done all at once. This segmentation may or may not take place at the run
time of the program.
 Simple Segmentation: Each process is divided into a number of segments, all of which are
loaded into memory at run time, though not necessarily contiguously.

4. Explain internal and external fragmentation.

1. Internal fragmentation :
 Internal fragmentation happens when the memory is split into mounted-sized blocks.
 Whenever a method is requested for the memory, the mounted-sized block is allotted
to the method.
 In the case where the memory allotted to the method is somewhat larger than the
memory requested, then the difference between allotted and requested memory is
called internal fragmentation.
 We fixed the sizes of the memory blocks, which has caused this issue. If we use
dynamic partitioning to allot space to the process, this issue can be solved.

2. External fragmentation :

 External fragmentation happens when there's a sufficient quantity of area within the
memory to satisfy the memory request of a method.
 However, the process’s memory request cannot be fulfilled because the memory
offered is in a non-contiguous manner.
 Whether you apply a first-fit or best-fit memory allocation strategy it'll cause external
fragmentation

Exclusive Paid Material by Campusify©


 In the above diagram, we can see that, there is enough space (55 KB) to run a process-
07 (required 50 KB) but the memory (fragment) is not contiguous. Here, we use
compaction, paging, or segmentation to use the free space to run a process

6 Marks Questions
1. Explain Free space management techniques ( Bit map, Linked List )

1. Bit Map :
 The free-space list is implemented as a bit map or bit vector. Each block is represented
by 1 bit.
 If the block is free, the bit is 1; if the block is allocated, the bit is 0.
 The given instance of disk blocks on the disk in below Figure (where green blocks are
allocated) can be represented by a bitmap of 16 bits as:
1111000111111001.

Exclusive Paid Material by Campusify©


Advantages:
 Simple to understand.
 Finding the first free block is efficient. It requires scanning the words (a group of 8 bits) in a
bitmap for a non-zero word. (A 0-valued word has all bits 0). The first free block is then
found by scanning for the first 1 bit in the non-zero word.
Disadvantages:
 For finding a free block, Operating System needs to iterate all the blocks which is time
consuming.
 The efficiency of this method reduces as the disk size increases.

2. Linked List :
 In this approach, the free disk blocks are linked together i.e. a free block contains a pointer to
the next free block.
 The block number of the very first disk block is stored at a separate location on disk and is
also cached in memory.
 In below figure, the free space list head points to Block 5 which points to Block 6, the next
free block and so on.
 The last free block would contain a null pointer indicating the end of free list. A drawback of
this method is the I/O required for free space list traversal.

Advantages:
 The total available space is used efficiently using this method.
 Dynamic allocation in Linked List is easy, thus can add the space as per the requirement
dynamically.
Disadvantages:
 When the size of Linked List increases, the headache of miniating pointers is also increases.
 This method is not efficient during iteration of each block of memory.

Exclusive Paid Material by Campusify©


2. Concept of virtual memory with respect to paging. Include diagram and example.

 Virtual memory is a memory management technique used by operating systems to give the
appearance of a large, continuous block of memory to applications, even if the physical
memory (RAM) is limited. It allows larger applications to run on systems with less RAM.

 The main objective of virtual memory is to support multiprogramming, The main advantage
that virtual memory provides is, a running process does not need to be entirely in memory.

 Programs can be larger than the available physical memory. Virtual Memory provides an
abstraction of main memory, eliminating concerns about storage limitations.

 A memory hierarchy, consisting of a computer system's memory and a disk, enables a process
to operate with only some portions of its address space in RAM to allow more processes to be
in memory.

Exclusive Paid Material by Campusify©


 A virtual memory is what its name indicates- it is an illusion of a memory
that is larger than the real memory. We refer to the software component of
virtual memory as a virtual memory manager. The basis of virtual memory
is the noncontiguous memory allocation model. The virtual memory
manager removes some components from memory to make room for other
components.

 The size of virtual storage is limited by the addressing scheme of the


computer system and the amount of secondary memory available not by the
actual number of main storage locations.

Paging :
 Paging divides memory into small fixed-size blocks called pages. When
the computer runs out of RAM, pages that aren't currently in use are moved
to the hard drive, into an area called a swap file.

 The swap file acts as an extension of RAM. When a page is needed again,
it is swapped back into RAM, a process known as page swapping.

 This ensures that the operating system (OS) and applications have enough
 memory to run.

Exclusive Paid Material by Campusify©


3. Difference between segmentation and paging (any 6 points).

Aspect Paging Segmentation

Basic Concept Divides memory into fixed-size Divides memory into variable-size
blocks called pages. blocks called segments.

Memory Both logical and physical memory are Logical memory is divided into
Division divided into equal-sized units. functional segments (e.g., code, stack).

Unit of Page (fixed size) Segment (variable size)


Division

Fragmentation May cause internal fragmentation. May cause external fragmentation.

Address Logical address = (Page Number, Logical address = (Segment Number,


Format Offset) Offset)

Use Case Common in general-purpose OS for Common in compiler design, supports


efficient memory use. modular program structure.

Transparency Program is unaware of paging. Segmentation is visible to the


programmer.

Translation Uses a Page Table to map logical Uses a Segment Table to map segments
Table pages to physical frames. to memory addresses.

Protection Protection is applied per page. Protection is applied per segment.

Exclusive Paid Material by Campusify©


NUMERICAL [PAGE REPLACEMENT]

First In First Out (FIFO)


This is the simplest page replacement algorithm. In this algorithm, the operating system keeps track of all pages
in the memory in a queue, the oldest page is in the front of the queue. When a page needs to be replaced page in
the front of the queue is selected for removal.

Example 1: Consider page reference string 1, 3, 0, 3, 5, 6, 3 with 3-page frames. Find the number of page faults
using FIFO Page Replacement Algorithm.

Optimal Page Replacement

In this algorithm, pages are replaced which would not be used for the longest duration of time in the future.

Example: Consider the page references 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 3 with 4-page frame. Find number of
page fault using Optimal Page Replacement Algorithm.

Exclusive Paid Material by Campusify©


Least Recently Used

In this algorithm, page will be replaced which is least recently used.

Example Consider the page reference string 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 3 with 4-page frames. Find
number of page faults using LRU Page Replacement Algorithm.

Page Replacement Algorithm

Given a page reference string with three (03) page frames. Calculate the page faults with ‘Optimal’ and ‘LRU’
page replacement algorithm respectively. ‘7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1 (Representation of frame can be
in any order).

Exclusive Paid Material by Campusify©


Exclusive Paid Material by Campusify©
OPERATING SYSTEM PAID
UNIT 5 NOTES

This Study Material is provided by [Link] ©


Made by Team Campusify
THIS IS THE PAID STUDY MATERIAL BY CAMPUSIFYPLUS!!

� Be Part of Our Community

Campusify Telegram Channel -


Campusify Whatsapp Channel - CLICK TO JOIN

Campusify is building the Biggest Diploma/Engineering Student Community in


Maharashtra. Be part of the movement!

Exclusive Paid Material by Campusify©


UNIT 5: File Management (10 marks)

2 Marks Questions
1. Describe any four file attributes.

 Name: The symbolic file name is the only information kept in human readable form.
 Identifier: File system gives a unique tag or number that identifies file within file system and
which is used to refer files internally.
 Type: This information is needed for those systems that support different types.
 Location: This information is a pointer to a device and to the location of the file on that device.
 Size: The current size of the file (in bytes, words or blocks) and possibly the maximum allowed
size are included in this attribute.
 Protection: Access control information determines that who can do reading, writing, executing
and so on. Time, Date and User
 Identification: This information may be kept for creation, Last modification and last use. These
data can be useful for protection, security and usage monitoring.

2. List any four operations performed on a file.

 Creating a file
 Writing a file
 Reading a file Repositioning within a file
 Deleting a file
 Appending new information to the end of the file
 Renaming an existing file
 Truncating a file
 Creating copy of a file, copy file to another I/O device such as printer or display

3. Enlist different file allocation methods?

Three major methods of allocating disk space are in wide use:

i. Contiguous

ii. Linked

iii. Indexed

Exclusive Paid Material by Campusify©


4 Marks Questions
1. File Concepts: Attributes, Operations, File types and File system structure

File Attributes :

 Name: The symbolic file name is the only information kept in human readable form.
 Identifier: File system gives a unique tag or number that identifies file within file system and
which is used to refer files internally.
 Type: This information is needed for those systems that support different types.
 Location: This information is a pointer to a device and to the location of the file on that device.
 Size: The current size of the file (in bytes, words or blocks) and possibly the maximum allowed
size are included in this attribute.
 Protection: Access control information determines that who can do reading, writing, executing
and so on. Time, Date and User
 Identification: This information may be kept for creation, Last modification and last use. These
data can be useful for protection, security and usage monitoring.

File Operations :

 Creating a file
 Writing a file
 Reading a file Repositioning within a file
 Deleting a file
 Appending new information to the end of the file
 Renaming an existing file
 Truncating a file
 Creating copy of a file, copy file to another I/O device such as printer or display

File Tpes :

 Text Files: Contain plain text data, such as documents, source code, or configuration files (e.g.,
.txt,csv,ini).
 Binary Files: Contain binary data, such as executable programs, images, audio, or video files
(e.g., .exe, .jpg, .mp3, .mp4).
 Executable Files: Contain machine code that can be executed directly by the computer's
processor (e.g., .exe, .bin).
 Data Files: Contain data used by applications, such as databases, spreadsheets, or documents
(e.g., .db, .xls, .docx).
 System Files: Contain system-specific data or configuration information, such as device drivers
or system settings (e.g., .sys, .dll).
 Archive Files: Contain compressed or archived data, such as zip files or tarballs (e.g., .zip, .tar,
.gz).
 Image Files: Contain graphical data, such as pictures or graphics (e.g., .jpg, .png, .gif).
 Audio Files: Contain audio data, such as music or sound effects (e.g., .mp3, .wav, .ogg).
 Video Files: Contain video data, such as movies or animations (e.g., .mp4, .avi, .mov).

Exclusive Paid Material by Campusify©


File System Structure :
 It dictates how data is stored, accessed, and retrieved, providing a framework for both the
operating system and users.
 The structure typically involves a hierarchical organization of directories and files, along with
metadata describing each file

2. Describe Accessing Methods : sequential and direct access.

Sequential Access Method :

 Information from the file is processed in order i.e. one record after another. It is commonly used
access mode.
 For example, editors and compilers access files in sequence. A read operation read information
from the file in a sequence i.e. read next reads the next portion of the file and automatically
advances a file pointer.
 A write operation writes information into the file in a sequence i.e. write next appends to the end
of the file and advances to the end of the newly written material.
 Such a file can be reset to the beginning. In some operating systems, a program may be able to
skip forward or backward n records for some integer n.

 As shown in above diagram, a file can be rewind (moved in forwward direction) from the
current position to start with beginning of the file or it can be read or write in forward direction.

Exclusive Paid Material by Campusify©


Direct Access Methods :
 It is also called as relative access. A file is made up of fixed length logical records that allow
programs to read and write records rapidly in no particular order.
 Direct access method is based on disk model of a file which allows random access to any file
block. For direct access a file is viewed as a numbered sequence of blocks or records. So we can
directly read block 14, then block 53 and so on.
 This method is used for immediate access to large amount of information. Database can be
accessed with direct access method.
 For example, when a query concerning a particular subject arrives, we compute which block
contains the answer and then read that block directly to provide the desired information.
 Read n operation is used to read the nth block from the file whereas write n is used to write in
that block. The block numbers provided by the user to the operating system is a relative block
number. A relative block number is an index relative to the beginning of the file.
 The first relative block of file is 0; the next is 1 and so on. Actual absolute disk address of the
block is different from the relative address.
 The use of relative block numbers allow the operating system to decide where the f ile should be
placed and helps t prevent the user from accessing portions of the file system that may not be
part of his file.

Exclusive Paid Material by Campusify©


6 Marks Questions
1. Explain File allocation methods in detail with advantages and disadvantages: Contiguous
allocation, Linked allocation, Indexed allocation

 From the user’s point of view, a file is an abstract data type. It can be created, opened, written,
read, closed and deleted without any real concern for its implementation.
 The implementation of a file is a problem for the operating system. The main problem is how to
allocate space to these files so that disk space is effectively utilized and files can be quickly
accessed.
 Three major methods of allocating disk space are in wide use:
Contiguous
Linked
Indexed

1. Contiguous Allocation :

 The contiguous allocation method requires each file to occupy a set of contiguous addresses on
the disk. Disk addresses define a linear ordering on the disk. Contiguous allocation of a file is
defined by the disk address of the first block and its length. If the file is ‘n’ blocks long and
starts at location ‘b’, then it occupies blocks b, b+1, b+2,----------b+n-1. The directory entry for
each file indicates the address of the starting block and the length of the area allocated for this
file.
 Contiguous allocation supports both sequential and direct access
 For direct access to block ‘i’ of a file, which starts at block ‘b’, we can immediately access block
b+i. The difficulty with contiguous allocation is finding space for a new file.
 For direct access to block ‘i’ of a file, which starts at block ‘b’, we can immediately access block
b+i.
 The difficulty with contiguous allocation is finding space for a new file.
 If file to be created are ‘n’ blocks long, we must search free space list for ‘n’ free contiguous
blocks.

Exclusive Paid Material by Campusify©


Advantages :
 Supports both sequential and direct access methods.
 Contiguous allocation is the best form of allocation for sequential files. Multiple blocks can be
brought in at a time to improve I/O performance for sequential processing.
 It is also easy to retrieve a single block from a file.
 Reading all blocks belonging to each file is very fast.
 Provides good performance.

Disadvantages :
 Suffers from external fragmentation.
 Very difficult to find contiguous blocks of space for new files.
 Also with pre-allocation, it is necessary to declare the size of the file at the time of creation which
many a times is difficult to estimate.
 Compaction may be required and it can be very expensive.

2. Linked List :
 In this scheme, each file is a linked list of disk blocks which need not be contiguous.
 The disk blocks can be scattered anywhere on the disk. The directory entry contains a pointer to
the starting and the ending file block.
 Each block contains a pointer to the next block occupied by the file. The file 'jeep' in following
image shows how the blocks are randomly distributed. The last block (25) contains -1 indicating a
null pointer and does not point to any other block.

Exclusive Paid Material by Campusify©


Advantages:

 This is very flexible in terms of file size. File size can be increased easily since the system
does not have to look for a contiguous chunk of memory.

 This method does not suffer from external fragmentation. This makes it relatively better in
terms of memory utilization.

Disadvantages:

 Because the file blocks are distributed randomly on the disk, a large number of seeks are
needed to access every block individually. This makes linked allocation slower.

 It does not support random or direct access. We can not directly access the blocks of a file. A
block k of a file can be accessed by traversing k blocks sequentially (sequential access ) from
the starting block of the file via block pointers.

 Pointers required in the linked allocation incur some extra overhead.

Indexed Allocation :
 In this scheme, a special block known as the Index block contains the pointers to all the
blocks occupied by a file.
 Each file has its own index block. The ith entry in the index block contains the disk address of
the ith file block.
 The directory entry contains the address of the index block as shown in the image:

Exclusive Paid Material by Campusify©


Advantages:
 This supports direct access to the blocks occupied by the file and therefore provides fast
access to the file blocks.
 It overcomes the problem of external fragmentation.
Disadvantages:
 The pointer overhead for indexed allocation is greater than linked allocation.
 For very small files, say files that expand only 2-3 blocks, the indexed allocation would keep
one entire block (index block) for the pointers which is inefficient in terms of memory
utilization. However, in linked allocation we lose the space of only 1 pointer per block.

2. Describe following directory structures in short with neat sketches: i) Single level ii) Two
level iii) Tree structured

Single level :

 It is the simplest form of directory structure, having one directory containing all the files, and
each file must have a unique name.
 Software design is simple. The advantages of this scheme are its simplicity and the ability to
locate files quickly.
 Since all files are in the same directory, they must have unique names. If there are two users who
call their data file "test", then the unique-name rule is violated.
 Even with a single-user, as the number of files increases, it becomes difficult to remember the
names of all the files in order to create files with unique name.

Two level :

 In the two-level structures, each user has its own user file directory (UFD). The UFD lists only
files of a single user.
 System contains a master file directory (MFD) which is indexed by user name or account number.
 Each entry in MFD points to the UFD for that user.
 When a user refers to a particular file, only his own UFD is searched. Different users can have
files with the same name, as long as all the file names within each UFD are unique.

Exclusive Paid Material by Campusify©


 When we create a file for a user, operating system searches only that user’s UFD to find whether
same name file already present in the directory. For deleting a file again operating system checks
the file name in the user’ UFD only.

Tree Dictionary Structure :

 In this directory structure user can create their own sub-directories and organize their files. The
tree has a root directory and every file has a unique path name.
 A directory contains a set of files or subdirectories. All directories have the same internal format.
One bit in each directory entry defines the entry as a file (0) or as a subdirectory (1).
 Each process has a current directory. Current directory contains files that are currently required by
the process.
 When reference is made to a file, the current directory is searched. If a file needed that is not in
the current directory, then the user usually must either specify a path name or change the current
directory.

Exclusive Paid Material by Campusify©

You might also like