Introduction to Operating system
Introduction to Operating system
AMAN SINGH
COMPUTER SCIENCE 3RD
YEAR
ROLL NO – 2513703
ENROLLMENT NO-
D2210019
[ OPERATING SYSTEM
]
An operating system (OS) is software that controls a computer's resources and manages how applications
INTRODUCTION TO
Introduction to Operating system
An operating system (OS) is a software that acts as an intermediary between computer hardware
and users. It manages and coordinates the activities of the computer's hardware and software,
ensuring efficient and effective use of resources.
Windows
macOS
Linux
Unix
Android
iOS
system software
System Software
System software serves as the foundation of a computer, managing hardware and enabling the
functioning of application software. It includes:
1. Operating Systems: The core software that manages hardware resources and provides
essential services, such as Windows, macOS, Linux, and Unix.
2. Device Drivers: Programs that allow the operating system to communicate with
hardware devices like printers, graphics cards, and network adapters.
3. Utilities: System maintenance tools, such as antivirus programs, disk defragmenters, and
backup software.
4. Firmware: Low-level software embedded in hardware devices, often providing basic
control and communication.
Application software
Application Software
Application software is designed to help users perform specific tasks or functions. It includes:
Key Differences
1. Purpose:
o System Software: Manages and controls hardware and provides a platform for
application software to run.
o Application Software: Enables users to accomplish specific tasks, such as word
processing, browsing the internet, or playing games.
2. Interaction:
o System Software: Interacts closely with hardware and performs essential
functions required by the system.
o Application Software: Interacts with system software to utilize hardware
resources for specific user tasks.
3. Necessity:
o System Software: Essential for the basic operation of a computer.
o Application Software: Not essential for basic operation, but necessary for
performing specific tasks.
4. Examples:
o System Software: Windows, macOS, Linux, device drivers, BIOS.
o Application Software: Microsoft Word, Adobe Photoshop, Google Chrome,
Candy Crush.
Description: These systems execute batches of jobs without manual intervention. Jobs
with similar needs are grouped together and processed in a sequence.
Example: Early mainframe systems like IBM's OS/360.
Advantages: Efficient for large volumes of similar tasks, reduced idle time.
Disadvantages: Lack of interactivity, long turnaround times for individual jobs.
Description: Multiple users can access the system simultaneously by sharing time slices
of the CPU. This provides an interactive computing environment.
Example: UNIX.
Advantages: Improved user interaction, efficient use of resources, reduced response
time.
Disadvantages: Complexity in managing resources, potential security issues due to
multiple users.
Description: These systems are designed to process data and events in real-time, with
strict time constraints. They are used in environments where timely execution is critical.
Example: VxWorks, QNX.
Advantages: Predictable behavior, high reliability and performance.
Disadvantages: Limited multitasking capabilities, high development and maintenance
costs.
Description: These systems manage a group of independent computers and make them
appear to the users as a single coherent system.
Example: Google’s MapReduce, Microsoft Azure.
Advantages: Resource sharing, improved reliability and availability.
Disadvantages: Network dependency, complexity in synchronization and data
consistency.
Description: These systems provide features for managing and using network resources,
allowing multiple computers to communicate and share resources.
Example: Novell NetWare, Windows Server.
Advantages: Centralized management, resource sharing, enhanced security.
Disadvantages: Dependency on network infrastructure, potential bottlenecks.
Description: Designed for mobile devices such as smartphones and tablets, these systems
are optimized for mobile hardware and touch interfaces.
Example: Android, iOS.
Advantages: User-friendly interfaces, optimized for mobile use, extensive app
ecosystems.
Disadvantages: Limited control and customization, potential security vulnerabilities
Multitasking –
Multitasking in an operating system (OS) refers to the ability to execute multiple tasks or processes
simultaneously. It allows multiple applications and processes to run concurrently, making efficient use of
the CPU and system resources.
1. Increased Productivity: By allowing multiple applications to run at the same time, users
can perform several tasks simultaneously, such as browsing the web while working on a
document or listening to music.
2. Efficient Resource Utilization: The OS allocates CPU time and system resources to
various tasks based on their priority and requirements, ensuring that resources are used
effectively.
3. Improved System Responsiveness: Multitasking allows the system to remain responsive
to user inputs and requests, even when multiple processes are running. This enhances the
overall user experience.
4. Parallel Processing: Multitasking enables parallel processing, where different parts of a
program or multiple programs can be executed simultaneously on multi-core processors,
leading to faster execution and better performance.
Significance of NOS
Centralized Management:
Network administrators can manage network resources, user accounts, and security
policies from a central location. This simplifies the administration and maintenance of the
network.
Resource Sharing:
NOS allows multiple computers to share resources such as files, printers, and
applications. This enhances efficiency and reduces redundancy within the network.
Robust security features, including user authentication, access control, and encryption,
ensure that network resources are protected from unauthorized access and potential
threats.
NOS provides file and print services, allowing users to access and share files and printers
across the network. This enables seamless collaboration and resource utilization.
Network Communication:
Scalability:
Network operating systems are designed to scale with the growth of the network. They
can accommodate an increasing number of users, devices, and resources without
compromising performance.
NOS includes features like redundancy, backup, and failover mechanisms to ensure
network reliability and minimize downtime in case of hardware or software failures.
Network administrators can create and manage user accounts and groups, assigning
specific permissions and roles to control access to network resources.
1. Purpose:
o Network Operating Systems: Focus on managing network resources, facilitating
communication, and ensuring security within a networked environment.
o Standalone Operating Systems: Primarily designed for single-user
environments, managing local resources without network-centric features.
2. Centralized vs. Decentralized Management:
o Network Operating Systems: Enable centralized management of resources, user
accounts, and security policies.
o Other Operating Systems: Management is typically decentralized, focusing on
individual devices.
3. Resource Sharing:
o Network Operating Systems: Emphasize resource sharing and collaboration
across the network.
o Other Operating Systems: Resource sharing is limited to local resources on
individual devices.
4. Security Features:
o Network Operating Systems: Implement advanced security measures to protect
network resources and data.
o Other Operating Systems: Security features are tailored to protect local
resources and user data.
Windows Server
Novell NetWare
Mobile operating systems are specialized software platforms designed for mobile devices like
smartphones, tablets, and wearable devices. These systems are optimized for the hardware and
touch interfaces commonly found on mobile devices. Some well-known mobile operating
systems include Android and iOS.
1. User Interface:
o Optimized for touch input with gestures, swipes, and multi-touch capabilities.
o Intuitive and responsive interfaces tailored for smaller screens.
2. App Ecosystem:
o Support for a wide range of mobile applications available through app stores (e.g.,
Google Play Store, Apple App Store).
o Easy app installation and updates.
3. Connectivity:
o Built-in support for wireless connectivity options such as Wi-Fi, Bluetooth, and
cellular networks.
o Seamless integration with cloud services for data synchronization and backup.
4. Power Management:
o Advanced power management features to extend battery life and optimize
performance.
o Efficient use of resources to minimize power consumption.
5. Security:
o Enhanced security measures such as biometric authentication (fingerprint, facial
recognition) and encryption.
o Regular security updates to protect against threats and vulnerabilities.
System call –
A system call is a mechanism that allows a program to request a service from the kernel of the operating
system. It serves as a bridge between user-space applications and the operating system's core functions,
enabling programs to perform tasks that require direct interaction with the hardware or core system
resources.
Importance of System Calls in Operating Systems:
User-Space Applications
User-space applications are programs that run outside the operating system's kernel.
Examples include web browsers, text editors, and games.
These applications operate in user mode, which restricts direct access to hardware and
critical system resources to ensure system stability and security.
1. Request: When a user-space application needs to perform a task that requires kernel
intervention (e.g., reading a file), it makes a system call.
2. Switch to Kernel Mode: The system call causes the CPU to switch from user mode to
kernel mode, granting the necessary privileges to execute the requested service.
3. Kernel Processing: The kernel processes the request, performing the necessary
operations (e.g., accessing the file system to read the requested data).
4. Return to User Mode: Once the kernel has completed the requested service, it switches
the CPU back to user mode and returns the results to the user-space application.
5. Application Continues: The user-space application continues execution, using the
results provided by the kernel.
Main functions of system calls are
System calls play a crucial role in an operating system, providing the interface between user-
space applications and kernel-space services. Here are the main functions of system calls:
1. Process Control:
o Creation and Termination: System calls like fork(), exec(), exit(), and
wait() are used to create, execute, and terminate processes. They enable process
management by allowing processes to be started, stopped, and synchronized.
o Scheduling: System calls manage the scheduling of processes, ensuring fair
allocation of CPU time among running processes.
2. File Management:
o Operations: System calls like open(), read(), write(), close(), and
unlink() allow user-space applications to perform operations on files and
directories. They enable file creation, reading, writing, closing, and deletion.
o Permissions: System calls also handle file permissions and access control,
ensuring that only authorized users can access or modify files.
3. Device Management:
o Communication: System calls facilitate communication between user-space
applications and hardware devices. For example, ioctl() allows applications to
send control commands to devices.
o Input/Output: System calls manage I/O operations, such as reading data from
input devices (e.g., keyboards) and writing data to output devices (e.g., printers).
4. Information Maintenance:
o Status Information: System calls like getpid(), getuid(), and alarm()
provide information about the system and processes. They allow applications to
retrieve process IDs, user IDs, and set timers.
o System Information: System calls can retrieve system information, such as
system uptime, memory usage, and hardware status.
5. Inter-Process Communication (IPC):
o Communication Mechanisms: System calls like pipe(), shmget(), msgsnd(),
and msgrcv() enable communication between processes. They facilitate data
exchange and synchronization through pipes, shared memory, message queues,
and semaphores.
6. Memory Management:
o Allocation and Deallocation: System calls like brk() and mmap() manage
memory allocation and deallocation for user-space applications. They ensure
efficient use of memory and prevent conflicts.
o Paging and Swapping: System calls handle paging and swapping, allowing
processes to use virtual memory and access data stored on disk.
Explain the process control system calls, such as fork(), exec(), wait(), and exit().
fork():
Purpose: fork() is used to create a new process. This new process is called the child
process, and the process that calls fork() is the parent process.
Behavior: When fork() is called, it creates an exact copy of the parent process,
including the code, data, and open files. The child process gets a unique process ID
(PID).
Return Values: fork() returns twice—once in the parent process and once in the child
process. In the parent, it returns the PID of the child; in the child, it returns 0.
exec():
Purpose: exec() is used to replace the current process image with a new process image.
Essentially, it runs a new program within the same process.
Behavior: There are several variants of exec(), such as execl(), execp(), and
execv(). When exec() is called, it loads the new program into the current process's
memory space, overwriting the existing program.
Return Values: exec() does not return on success because the new program replaces the
current one. If it fails, it returns -1.
wait():
Purpose: wait() and its variants (such as waitpid()) are used by a parent process to
wait for the termination of its child processes.
Behavior: When the parent calls wait(), it blocks until one of its child processes exits.
The exit status of the terminated child process can be retrieved.
Return Values: wait() returns the PID of the terminated child process. If an error
occurs, it returns -1.
exit():
System calls are critical in providing an interface between user applications and kernel services.
They serve as the primary mechanism through which user-space applications interact with the
operating system's kernel to request various services. Here's how system calls fulfill this role:
Interface Mechanism
1. Controlled Access:
o Security and Protection: System calls provide a controlled and secure way for
user applications to access kernel services. This ensures that user applications
cannot directly access hardware or critical system resources, protecting the system
from accidental or malicious actions.
2. Transition Between Modes:
o User Mode to Kernel Mode: When a system call is invoked, the CPU transitions
from user mode to kernel mode. This switch allows the operating system to
perform tasks that require higher privileges, such as hardware access or process
management.
o Kernel Mode to User Mode: After the kernel completes the requested service,
the CPU transitions back to user mode, returning control to the user application.
System calls can be categorized into several groups based on their functionality and the services
they provide. Here are the main categories of system calls:
1. Process Control
System calls in this category manage processes, including their creation, execution,
synchronization, and termination.
2. File Management
These system calls handle file operations, such as creating, reading, writing, and deleting files.
3. Device Management
System calls in this category manage communication between user applications and hardware
devices.
These system calls provide information about the system and processes.
System calls in this category enable communication and synchronization between processes.
6. Memory Management
These system calls manage memory allocation and deallocation for processes.
brk(): Changes the location of the program break, increasing or decreasing the amount of
memory allocated to a process.
mmap(): Maps files or devices into memory, providing efficient file I/O.
file system-
A file system is a method and data structure that the operating system uses to control
how data is stored, organized, and retrieved on storage devices like hard drives,
SSDs, and USB drives. It provides a way for users and applications to store and
access files in a structured and efficient manner.
File
Definition: A file is a collection of data or information that is stored on a storage device.
Files can contain various types of data, such as text, images, videos, executables, and
more.
Purpose: Files are used to store and organize data for specific tasks or applications.
Naming: Each file has a unique name and often an extension (e.g., .txt, .jpg, .exe)
that indicates the type of data it contains.
Examples: A document (report.docx), an image (photo.jpg), a video (movie.mp4), a
program (game.exe).
Directory
Definition: A directory (or folder) is a special type of file that can contain other files and
directories. It provides a way to organize and manage files in a hierarchical structure.
Purpose: Directories are used to group related files and subdirectories together, making it
easier to navigate and manage the file system.
Naming: Each directory has a unique name within its parent directory. Unlike files,
directories do not have extensions.
Contain other
3. No. Yes.
same entity
Characteristics:
o Simple and widely supported by various operating systems, including Windows,
macOS, and Linux.
o Suitable for small storage devices like USB flash drives and memory cards.
o Limited file and volume size (FAT32 supports files up to 4GB and volumes up to
2TB).
Variants: FAT12, FAT16, FAT32.
Use Cases: Portable storage devices, compatibility across different platforms.
Characteristics:
o Developed by Microsoft for Windows operating systems.
o Supports large file and volume sizes, with built-in security features like file
permissions and encryption.
o Provides features like journaling, which helps recover data in case of a system
crash, and support for large storage devices.
o Efficient space management and file compression.
Use Cases: Windows-based systems, internal and external hard drives.
Characteristics:
o Developed for Linux operating systems.
o Supports large file and volume sizes, journaling, and file system snapshots.
o Extents-based file allocation, which improves performance and reduces
fragmentation.
o Backward compatible with ext3 and ext2 file systems.
Use Cases: Linux-based systems, internal and external storage devices.
Characteristics:
o Developed by Apple for macOS.
o Supports large file and volume sizes, journaling, and Unicode file names.
o Efficient space management and support for file system quotas.
Use Cases: macOS-based systems, internal and external storage devices.
Characteristics:
o The successor to HFS+, designed for modern storage technologies like SSDs.
o Features include strong encryption, space sharing, snapshots, and fast directory
sizing.
o Optimized for performance and reliability.
Use Cases: macOS, iOS, and other Apple devices.
Characteristics:
o Developed by Microsoft, designed to address the limitations of FAT32.
o Supports large files and volumes, without the limitations of FAT32.
o Compatible with both Windows and macOS.
Use Cases: Portable storage devices, cross-platform compatibility.
1. Contiguous Allocation
Description: Files are stored in contiguous blocks of disk space. Each file occupies a
continuous sequence of blocks.
Advantages: Simple to implement, efficient for sequential file access.
Disadvantages: Can lead to fragmentation, making it difficult to find contiguous free
space for new files.
2. Linked Allocation
Description: Files are stored as linked lists of disk blocks. Each block contains a pointer
to the next block in the file.
Advantages: Eliminates fragmentation issues, allows files to grow easily.
Disadvantages: Slower access time due to pointer traversal, overhead of storing pointers.
3. Indexed Allocation
Description: Each file has an index block that contains pointers to the data blocks of the
file. The index block provides direct access to the file's data blocks.
Advantages: Fast random access to file data, supports dynamic file growth.
Disadvantages: Overhead of storing index blocks, limited by the size of the index block.
4. Extent-Based Allocation
Description: Files are stored in extents, which are contiguous blocks of disk space. A file
may consist of multiple extents.
Advantages: Efficient for large files, reduces fragmentation.
Disadvantages: More complex to manage compared to simple contiguous or linked
allocation.
File systems also manage free disk space using various techniques to keep track of available
space:
Free List: A linked list of free disk blocks. Each entry in the list points to a free block.
Bitmap: A bitmap where each bit represents a disk block. A bit value of 0 indicates a free
block, while a bit value of 1 indicates an occupied block.
Grouping: Free blocks are grouped together, and each group contains a pointer to the
next group of free blocks.
Counting: Instead of listing all free blocks, the file system keeps track of the first free
block and the number of contiguous free blocks following it
The directory structure in an operating system serves several important purposes, ensuring
efficient data management and organization. Here are the main functions:
1. Organization of Files
Pathnames: The directory structure allows the use of pathnames to locate files and
directories. Absolute paths specify the location from the root directory, while relative
paths specify the location relative to the current directory.
Efficient Access: Users can navigate the file system using directory commands (e.g., cd,
ls, mkdir), making file access efficient and intuitive.
3. File Management
Creation and Deletion: The directory structure enables the creation, deletion, and
renaming of files and directories, providing a systematic way to manage data.
Storage Organization: Directories help in organizing storage space by segmenting it
into manageable sections, reducing clutter and improving file management.
4. Access Control
Permissions: The directory structure supports file and directory permissions, allowing
users and administrators to control access to data. Permissions can be set to restrict or
grant read, write, and execute access.
Security: By organizing files into directories with specific permissions, the system can
enhance data security and prevent unauthorized access.
5. Resource Allocation
Space Management: The directory structure assists in managing disk space allocation. It
keeps track of free and used space, ensuring efficient storage utilization and preventing
fragmentation.
Metadata Management: Directories store metadata about files, such as creation date,
modification date, size, and permissions, helping in efficient resource allocation.
File Operations: The directory structure provides a framework for file operations like
copying, moving, and searching files. It enables commands and functions that operate on
files and directories to work effectively.
Directory structures in an operating system can be organized in various ways, each with its own
characteristics and use cases. Here are the main types:
1. Single-Level Directory
Description: All files are stored in a single directory at the same level.
Advantages: Simple to implement and easy to understand.
Disadvantages: Not suitable for systems with a large number of files, as it can become
cluttered and difficult to manage. No way to group related files together.
2. Two-Level Directory
Description: Each user has a separate directory at the top level, and within each user's
directory, files are stored.
Advantages: Provides a way to segregate files by user, improving organization and
security.
Disadvantages: Does not allow for further structuring within a user's directory. Users
cannot share files easily without complex permissions.
3. Hierarchical Directory
Description: The directory structure is organized as a tree, with a root directory at the
top, and subdirectories branching out.
Advantages: Supports a complex, organized, and scalable file system. Allows for easy
navigation and grouping of related files.
Disadvantages: More complex to implement and manage compared to single-level or
two-level directories.
Description: Similar to a hierarchical directory, but allows shared files and directories
using links, forming an acyclic graph (no cycles).
Advantages: Facilitates sharing of files and directories without duplication. Efficient use
of storage.
Disadvantages: Can become complex to manage links and ensure that the structure
remains acyclic.
Description: An extension of the acyclic graph directory that allows cycles, meaning
directories can be linked in a way that forms a loop.
Advantages: Provides maximum flexibility for linking and organizing files and
directories.
Disadvantages: Complexity in managing and maintaining the directory structure.
Potential issues with navigation and file access due to cycles.
Directory
Description Advantages Disadvantages
Structure
Simple, easy to Not scalable, cluttered with
Single-Level All files in a single directory
understand many files
Separate directory for each Organized by user, Limited structure within user
Two-Level
user improved security directories
Tree-like structure with root Organized, scalable,
Hierarchical More complex to manage
and subdirectories easy navigation
Tree structure with shared Efficient sharing, no Complex link management,
Acyclic Graph
files using links (no cycles) duplication maintain acyclic structure
Allows cycles, maximum Flexible file and Complex, potential
General Graph
flexibility in linking directory linking navigation and access issues
1. Tracks:
o Description: Tracks are concentric circular paths on the surface of the disk
platters where data is magnetically recorded and read.
o Function: Each track holds a portion of the data, and tracks are numbered
sequentially from the outer edge to the inner edge of the disk platter.
2. Sectors:
o Description: Tracks are divided into smaller units called sectors. Each sector
typically holds 512 bytes or 4096 bytes of data.
o Function: Sectors are the smallest units of storage on the disk. The combination
of tracks and sectors forms a grid-like structure on the disk surface, enabling
precise data retrieval.
3. Cylinders:
o Description: A cylinder is a set of tracks located at the same position on each
disk platter. Imagine a stack of disks, where each disk has tracks aligned
vertically. A cylinder includes all tracks at a specific radial distance from the
center, across all platters.
o Function: Cylinders are used to simplify the addressing and data management on
the disk. When the read/write heads are positioned over a cylinder, they can read
or write data on all the platters simultaneously without moving.
Visualization-
Physical Disk Structure
The physical disk structure refers to the actual hardware components and the way data is
organized on the storage medium. It includes:
1. Platters: Circular disks coated with magnetic material, where data is stored.
2. Tracks: Concentric circles on the surface of each platter where data is recorded.
3. Sectors: Smallest units of data storage within a track. Each sector typically holds 512
bytes or 4096 bytes of data.
4. Cylinders: A set of tracks located at the same position on each platter, forming a
cylindrical shape.
5. Read/Write Heads: Mechanisms that move across the platters to read and write data.
6. Spindle: The axis that rotates the platters.
The logical disk structure refers to the way the operating system organizes and manages data on
the disk. It abstracts the physical structure and presents a logical view to the users and
applications. It includes:
1. Partitions: Logical divisions of the disk, which can be formatted with different file
systems. Each partition can act as a separate logical disk.
2. File Systems: Structures that define how data is stored, organized, and accessed on the
disk (e.g., FAT, NTFS, ext4).
3. Directories and Files: Hierarchical structures that organize data into files and folders.
4. Logical Blocks: Units of data storage managed by the file system. Logical blocks map to
physical sectors on the disk.
Key Differences
1. Pipes:
o Description: A pipe is a unidirectional communication channel that allows data to
flow from one process to another.
o System Calls: pipe()
o Usage: Useful for parent-child process communication. The parent process
creates a pipe and both processes can read from or write to it.
2. Named Pipes (FIFOs):
o Description: Similar to pipes, but have a name in the file system and can be used
for communication between unrelated processes.
o System Calls: mkfifo()
o Usage: Allows unrelated processes to communicate through a named pipe in the
file system.
3. Message Queues:
o Description: Message queues allow processes to exchange messages in a queued
manner, providing asynchronous communication.
o System Calls: msgget(), msgsnd(), msgrcv(), msgctl()
o Usage: Suitable for complex communication scenarios where multiple processes
need to send and receive messages.
4. Shared Memory:
o Description: Shared memory allows multiple processes to access the same
memory space, enabling fast and direct data exchange.
o System Calls: shmget(), shmat(), shmdt(), shmctl()
o Usage: Efficient for large data transfers, as it avoids copying data between
processes.
5. Semaphores:
o Description: Semaphores are synchronization tools used to control access to
shared resources and prevent race conditions.
o System Calls: semget(), semop(), semctl()
o Usage: Useful for managing access to shared resources, ensuring mutual
exclusion and coordination among processes.
6. Sockets:
o Description: Sockets provide communication between processes over a network
or on the same machine.
o System Calls: socket(), bind(), listen(), accept(), connect(), send(),
recv()
o Usage: Essential for network communication, enabling processes to send and
receive data over TCP/IP or other protocols.
A process and a program are related concepts in computing, but they have distinct differences.
Program
Process
. New
Description: The process is in the creation phase. The operating system is setting up the
process control block (PCB) and allocating necessary resources.
State Transition: Once the process is ready to be executed, it transitions to the ready
state.
2. Ready
Description: The process is in the ready queue, waiting for CPU time. It has all the
resources it needs, but it's not currently executing.
State Transition: When the scheduler selects the process, it transitions to the running
state.
3. Running
4. Waiting (Blocked)
Description: The process is waiting for an event to occur (e.g., I/O completion, signal). It
cannot continue execution until the event is resolved.
State Transition: Once the event occurs, the process transitions back to the ready state.
5. Terminated
Description: The process has completed its execution and is being removed from
memory. All resources allocated to the process are released.
State Transition: The process no longer transitions to any other state, as it has finished
its lifecycle.
Summary
Context switching-
Context switching is the process by which the operating system saves the state of
a currently running process and restores the state of another process. This allows
multiple processes to share a single CPU and appear to execute concurrently.
1. Multitasking:
o Context switching enables multitasking by allowing multiple processes to share
the CPU. It ensures that each process gets a fair share of CPU time, making the
system responsive to user inputs.
2. Efficient CPU Utilization:
o By rapidly switching between processes, the CPU can maximize its utilization and
minimize idle time, improving overall system performance.
3. Process Isolation:
o Context switching helps in maintaining process isolation and security. Each
process operates in its own virtual environment, preventing interference from
other processes.
4. Responsiveness:
o It enhances system responsiveness by allowing high-priority processes to be
executed promptly, such as responding to user inputs or handling real-time tasks.
Virtual memory
Virtual memory is a memory management technique that allows an operating system to use
more memory than what is physically available on the system. It creates an illusion for users that
there is unlimited memory available, by using disk space as an extension of RAM. This enables
efficient and seamless execution of programs, even when the physical RAM is insufficient.
Paging: The operating system divides both physical memory (RAM) and virtual memory
into fixed-size blocks called pages. When a program needs to access data that is not
currently in RAM, a page fault occurs, and the operating system retrieves the required
page from disk and loads it into RAM.
Segmentation: Memory is divided into segments of variable sizes, each representing a
logical unit such as a function or data array. Segmentation provides a way to protect and
manage memory allocation at a higher level of abstraction.
Thrashing
Thrashing is a condition in which a system spends most of its time swapping pages in and out of
memory, rather than executing actual processes. This typically occurs when there is insufficient
physical memory (RAM) to accommodate all the active processes, leading to excessive paging
and a significant drop in system performance.
The operating system manages memory allocation and deallocation using various techniques and
strategies to ensure efficient use of memory resources and to maintain system stability. Here are
the key concepts and methods involved:
Memory Allocation
Memory allocation refers to the process of assigning memory blocks to processes or programs.
There are two main types of memory allocation:
1. Static Allocation:
o Description: Memory is allocated at compile-time and remains fixed throughout
the program's execution.
o Example: Global variables and static variables.
2. Dynamic Allocation:
o Description: Memory is allocated at runtime based on the program's needs. This
allows for more flexible and efficient use of memory.
o Example: Dynamic memory allocation using functions like malloc(), calloc(),
and realloc() in C.
The operating system employs various techniques to manage memory allocation and
deallocation:
1. Paging:
o Description: Memory is divided into fixed-size pages, and the physical memory
is divided into fixed-size frames. Pages are mapped to frames using a page table,
allowing non-contiguous memory allocation and eliminating external
fragmentation.
o Benefits: Simplifies memory allocation, enables efficient use of memory, and
supports virtual memory.
2. Segmentation:
o Description: Memory is divided into variable-sized segments based on the logical
divisions of a program, such as functions or data structures. Each segment has its
own base address and limit.
o Benefits: Provides a logical view of memory, facilitates sharing and protection,
and enables efficient use of memory.
3. Buddy System:
o Description: Memory is divided into blocks of varying sizes that are powers of
two. When a block is allocated, it is split into smaller blocks if necessary. When a
block is deallocated, it is merged with its "buddy" block if possible.
o Benefits: Reduces fragmentation and allows efficient memory allocation and
deallocation.
Memory Allocation Strategies
1. First Fit:
o Description: Allocates the first available memory block that is large enough to
accommodate the request.
o Advantages: Simple and fast.
o Disadvantages: Can lead to fragmentation.
2. Best Fit:
o Description: Allocates the smallest available memory block that is large enough
to accommodate the request.
o Advantages: Reduces wasted memory.
o Disadvantages: Can lead to fragmentation and longer allocation times.
3. Worst Fit:
o Description: Allocates the largest available memory block that is large enough to
accommodate the request.
o Advantages: Reduces the chance of small fragmented blocks.
o Disadvantages: Can lead to inefficient memory use.
Memory Deallocation
Memory deallocation refers to the process of releasing memory blocks that are no longer needed
by a program. The operating system uses various techniques to manage deallocation:
1. Garbage Collection:
o Description: An automated process that identifies and reclaims memory that is no
longer in use by the program.
o Example: Java's garbage collector.
2. Manual Deallocation:
o Description: The programmer explicitly frees memory using functions like
free() in C.
o Advantages: Gives the programmer control over memory management.
o Disadvantages: Can lead to memory leaks and dangling pointers if not managed
correctly.
File system in operating system
A file system is a crucial component of an operating system that manages how data is stored,
organized, and retrieved on a storage device, such as a hard drive, SSD, or USB drive. It
provides a systematic way to store, access, and manage files, ensuring efficient data
management.
File access control is a security mechanism used to regulate and manage who can read, write,
execute, or otherwise interact with a file or directory in a file system. It ensures that only
authorized users or processes can access certain files or perform specific operations on them.
1. Permissions:
o Read (r): Allows the user to view the contents of a file.
o Write (w): Allows the user to modify or delete the contents of a file.
o Execute (x): Allows the user to execute the file if it is a program or script.
2. Access Control Lists (ACLs):
o Description: ACLs provide a more granular way of specifying permissions. They
list individual users or groups and their specific permissions for a file or directory.
3. User and Group Ownership:
o User: The owner of the file.
o Group: A group of users who have certain permissions for the file.
1. Data Security:
o File access control helps protect sensitive data from unauthorized access, ensuring
that only authorized users can view or modify it.
2. Privacy:
o It ensures that personal or confidential information is kept private and is not
accessible to unauthorized individuals.
3. Integrity:
o By restricting write access, file access control helps maintain the integrity of data,
preventing unauthorized modifications or deletions.
4. Compliance:
o Many industries have regulatory requirements for data protection. File access
control helps organizations comply with these regulations by enforcing access
policies.
5. Resource Management:
o It prevents unauthorized users from consuming system resources, ensuring that
only legitimate users can access and use them.
File Attributes
File attributes are properties or characteristics of a file that provide information about its state
and how it should be treated by the operating system and applications. Common file attributes
include:
1. Read-Only:
o Description: Indicates that the file can be read but not modified. Useful for
protecting important files from accidental changes.
2. Hidden:
o Description: Prevents the file from being displayed in standard directory listings.
Hidden files are often system or configuration files.
3. System:
o Description: Marks the file as a system file, which is essential for the operating
system's operation. These files are usually protected from user access.
4. Archive:
o Description: Indicates that the file has been modified since the last backup. Used
by backup software to identify files that need to be saved.
5. Executable:
o Description: Indicates that the file can be executed as a program or script.
File Metadata
File metadata is data that provides information about a file's properties, content, and structure.
Metadata helps the operating system and applications manage, organize, and access files
efficiently. Common file metadata includes:
1. File Name:
o Description: The name of the file, which is used to identify it in the file system.
2. File Size:
o Description: The amount of data contained in the file, usually measured in bytes.
3. Creation Date:
o Description: The date and time when the file was created.
4. Modification Date:
o Description: The date and time when the file was last modified.
5. Access Date:
o Description: The date and time when the file was last accessed (read).
6. File Permissions:
o Description: Information about who can read, write, or execute the file (e.g.,
owner, group, others).
7. File Type:
o Description: The format of the file, often indicated by the file extension
(e.g., .txt, .jpg, .exe).
8. Location:
o Description: The path to the file in the file system hierarchy.
A hierarchical file system structure organizes files and directories in a tree-like structure, with
directories containing other directories and files. This organization offers several key benefits:
Logical Grouping: Files are logically grouped into directories and subdirectories,
making it easier to organize and manage data.
Hierarchical Navigation: The tree-like structure allows users to navigate through the file
system efficiently, locating and accessing files with ease.
2. Scalability
Large Volume Support: The hierarchical structure can accommodate a large number of
files and directories, making it suitable for systems with extensive data storage needs.
Expandable: New directories and files can be added to the structure without disrupting
existing organization.
4. Data Retrieval
Efficient Search: The hierarchical structure supports efficient file searches, as the search
scope can be limited to specific directories or subdirectories.
Path Resolution: Using absolute and relative paths, users and applications can quickly
locate and access files.
6. Resource Management
Space Allocation
1. Confidentiality
Description: Ensuring that sensitive data is accessible only to authorized users and
processes.
Techniques: Encryption, access controls, and user authentication mechanisms.
2. Integrity
Description: Ensuring that data and system resources are accurate, consistent, and
protected from unauthorized modification.
Techniques: Checksums, digital signatures, and integrity verification mechanisms.
3. Availability
Description: Ensuring that system resources and services are available to authorized
users when needed.
Techniques: Redundancy, failover mechanisms, and denial-of-service (DoS) protection.
4. Authentication
Description: Verifying the identity of users and processes before granting access to
resources.
Techniques: Passwords, multi-factor authentication (MFA), biometrics, and secure
tokens.
5. Authorization
Description: Monitoring and recording user activities and system events to ensure
accountability and detect potential security breaches.
Techniques: Audit logs, security information and event management (SIEM) systems,
and regular security audits.
7. Non-Repudiation
Description: Ensuring the system can recover from security incidents and continue to
operate securely.
Techniques: Backup and recovery solutions, incident response plans, and disaster
recovery procedures.
1. Password-Based Authentication:
o Description: Users provide a username and a secret password to gain access. The
system checks the credentials against a stored database of user information.
o Advantages: Simple and widely used.
o Disadvantages: Can be vulnerable to attacks like brute force, phishing, and
password guessing if passwords are weak or not managed properly.
2. Multi-Factor Authentication (MFA):
o Description: Combines two or more authentication factors to enhance security.
These factors can be something the user knows (password), something the user
has (smartphone or token), or something the user is (biometric).
o Advantages: Provides an additional layer of security.
o Disadvantages: Can be more complex to implement and use.
3. Biometric Authentication:
o Description: Uses unique physical characteristics of the user, such as fingerprints,
facial recognition, retina scans, or voice recognition.
o Advantages: Difficult to forge, convenient for users.
o Disadvantages: Requires special hardware, privacy concerns.
4. Token-Based Authentication:
o Description: Users are provided with a token (physical or digital) that they use to
authenticate. Examples include hardware tokens, software tokens, and one-time
passwords (OTPs) sent to a mobile device.
o Advantages: Secure, especially when used in conjunction with other methods.
o Disadvantages: Tokens can be lost or stolen.
5. Certificate-Based Authentication:
o Description: Uses digital certificates issued by a trusted certificate authority
(CA). The user's identity is verified by validating the certificate.
o Advantages: Highly secure, suitable for secure communications and transactions.
o Disadvantages: Requires a public key infrastructure (PKI) and certificate
management.
6. Smart Card Authentication:
o Description: Uses a smart card containing embedded integrated circuits to store
authentication data. Users insert the card into a reader and provide a PIN.
o Advantages: Secure and portable.
o Disadvantages: Requires smart card readers and card management.
7. Single Sign-On (SSO):
o Description: Allows users to authenticate once and gain access to multiple
systems or applications without needing to re-enter credentials.
o Advantages: Enhances user experience, reduces password fatigue.
o Disadvantages: If compromised, it can provide access to multiple resources.
Key Differences
Security policy
Operating systems enforce security policies through a combination of mechanisms and tools
designed to protect data and resources. Here are some of the key methods:
1. Access Control
User Authentication: Verifying the identity of users through methods like passwords,
biometrics, and multi-factor authentication (MFA).
Authorization: Granting or denying permissions to access specific resources based on
the authenticated identity using access control lists (ACLs) or role-based access control
(RBAC).
File Permissions: Setting read, write, and execute permissions for files and directories to
control access.
Resource Access Controls: Regulating access to system resources like memory, CPU,
and network interfaces to prevent unauthorized usage.
3. Auditing and Monitoring
Audit Logs: Recording user activities and system events to monitor for suspicious
behavior and ensure accountability.
Intrusion Detection Systems (IDS): Monitoring network and system activities for
potential security breaches or malicious activity.
4. Encryption
Data Encryption: Protecting data at rest and in transit using encryption algorithms to
ensure confidentiality and integrity.
Secure Communication: Implementing protocols like SSL/TLS to secure
communication between devices and services.
Security Policies: Defining and enforcing security policies that outline acceptable use,
access controls, and security requirements.
Configuration Management: Ensuring systems are securely configured and updated to
prevent vulnerabilities.
User Accounts: Creating and managing user accounts with appropriate access levels and
permissions.
Group Management: Organizing users into groups to simplify permission management
and enforce group-based security policies.
7. Patch Management
Software Updates: Regularly applying patches and updates to operating systems and
applications to fix security vulnerabilities and improve defenses.
8. Malware Protection
File systems also manage free disk space using various techniques to keep track of available
space:
1. Free List:
o Description: A linked list of free disk blocks. Each entry in the list points to a
free block.
o Advantages: Simple to implement, easy to traverse.
o Disadvantages: Can become inefficient with large lists.
2. Bitmap:
o Description: A bitmap where each bit represents a disk block. A bit value of 0
indicates a free block, while a bit value of 1 indicates an occupied block.
o Advantages: Efficient for tracking large amounts of free space.
o Disadvantages: Requires additional memory for the bitmap.
3. Grouping:
o Description: Free blocks are grouped together, and each group contains a pointer
to the next group of free blocks.
o Advantages: Reduces the overhead of managing free space.
o Disadvantages: Can be complex to implement.
4. Counting:
o Description: Instead of listing all free blocks, the file system keeps track of the
first free block and the number of contiguous free blocks following it.
o Advantages: Efficient for managing large contiguous free spaces.
o Disadvantages: Less flexible for non-contiguous free space.