0% found this document useful (0 votes)
4 views29 pages

Chapter Two Three

The document provides an overview of Input/Output (I/O) subsystem management, detailing its key functions such as device independence, error handling, and buffering. It explains the differences between Hard Disk Drives (HDDs) and Solid State Drives (SSDs), including their advantages and disadvantages, and discusses various I/O operations, buffering techniques, and disk scheduling algorithms. Additionally, it covers RAID technology for data redundancy and performance improvement in storage systems.

Uploaded by

kamgayannick688
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views29 pages

Chapter Two Three

The document provides an overview of Input/Output (I/O) subsystem management, detailing its key functions such as device independence, error handling, and buffering. It explains the differences between Hard Disk Drives (HDDs) and Solid State Drives (SSDs), including their advantages and disadvantages, and discusses various I/O operations, buffering techniques, and disk scheduling algorithms. Additionally, it covers RAID technology for data redundancy and performance improvement in storage systems.

Uploaded by

kamgayannick688
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

LECTURE NOTES

2.1. Introduction to I/O Subsystem Management


The Input/Output (I/O) subsystem is a critical component of an operating system (OS)
responsible for managing interactions between the computer's hardware and software. It handles
data transfer between the CPU, memory, and peripheral devices, ensuring efficient, reliable, and
secure operations. The I/O subsystem abstracts hardware complexities from applications,
providing a uniform interface while optimizing performance and resource utilization.
Key Functions of I/O Subsystem Management
 Device Independence: Allows programs to access devices without knowing hardware
specifics (e.g., reading from a file regardless of whether it's on a HDD or SSD).
 Error Handling: Detects and recovers from I/O errors, such as bad sectors on disks.
 Buffering and Caching: Temporarily stores data to bridge speed differences between CPU
and devices.
 Scheduling: Manages I/O requests to minimize wait times and optimize throughput.
 Spooling: Queues output for slow devices like printers to free up CPU time.
What do we mean by queuing?
Advantages of Effective I/O Management
 Improves system performance by reducing CPU idle time.
 Enhances reliability through error detection and recovery.
 Supports multitasking by allowing concurrent I/O operations.
Disadvantages I/O Management
 Adds overhead in terms of OS code complexity and potential latency from abstraction
layers.
 Poor I/O management can lead to bottlenecks, especially in I/O-bound systems.
The concept of I/O management is experienced in web servers, efficient I/O management
handles thousands of concurrent file reads/writes. In embedded systems like IoT devices, it
optimizes power consumption during sensor data transfers.

2.2 Introduction to I/O Devices


I/O devices are hardware components that facilitate data exchange with the computer. They are
categorized based on data transfer methods, speed, and functionality.

Types of I/O Devices


 Block Devices: Handle data in fixed-size blocks (e.g., 512 bytes or 4KB). Examples:
Hard Disk Drives (HDDs), Solid-State Drives (SSDs), USB flash drives. These are
suitable for random access and large data volumes.

1|Page
LECTURE NOTES

 Character Devices: Transfer data one character (byte) at a time. Examples: Keyboards,
mice, serial ports, printers. These are used for sequential, low-volume data streams.

Device Controllers
A device controller is a hardware interface (chip or card) that manages communication between
the device and the system bus. It handles low-level operations like converting digital signals to
mechanical actions (e.g., moving a disk head).
Examples: SATA controllers for HDDs/SSDs, USB controllers for peripherals.
Advantages: Offloads CPU work, supports multiple devices per controller.
Disadvantages: Can become a bottleneck if overloaded; failures affect connected devices.
What is a bus? Classify them in categories.

Interrupts
Interrupts are signals from devices to the CPU indicating an event (e.g., data ready or operation
complete). They allow asynchronous I/O, freeing the CPU for other tasks.
Types:
 Hardware Interrupts: From devices (e.g., keyboard press).
 Software Interrupts (Traps): From programs (e.g., system calls for I/O).
Advantages: Efficient for unpredictable events; reduces CPU polling overhead.
Disadvantages: Interrupt handling adds context-switching overhead; too many can cause
"interrupt storms."

2|Page
LECTURE NOTES

We experiment this in real-time systems like gaming, interrupts ensure quick response to user
input (e.g., mouse clicks).
Give a real life scenario to describe an interrupt you usually face with related devices such as
your phone.

Give examples of maskable and non-maskable interrupts that exist in the computer system. Use
a table to differentiate them.

HARD DISK DRIVES / SOLID STATE DRIVES

3|Page
LECTURE NOTES

Hard Disk Drives (HDD) and Solid State Drives (SSD) are two types of storage devices used to
store data on computers,laptops, and other devices. While HDDs have been around for decades,
SSDs are a newer, faster, and more advanced technology. The main difference between them lies
in how they store and access data. Let's look at the fundamental distinctions between HDD and
SSD.
What is a Hard Disk Drive(HDD)?
An HDD consists of a spinning disk (platter) coated with a magnetic material and a read/write
head that reads and writes data on the disk's surface. The read/write head moves back and forth
across the spinning disk to access different parts of the data stored on the disk. HDDs have been
around for decades and are the more traditional type of storage device.

How do HDDs work?


A Hard Disk Drive (HDD) works by using spinning disks and a moving read/write head to store
and retrieve data. Inside the HDD, there are platters coated with a magnetic material that spin at
high speeds, usually 5400 or 7200 RPM. A tiny read/write head moves across these spinning
platters without touching them, reading and writing data by detecting small magnetic charges.
The platters are divided into tracks and sectors, which act like an address system to help locate
stored information. When you save a file, the HDD records data by changing the magnetic
charges at specific locations. When you open a file, the HDD finds the correct location, and the
read head retrieves the data, which is then sent to the computer. An I/O controller manages

4|Page
LECTURE NOTES

communication between the HDD and the computer, ensuring data is accessed correctly. Since
HDDs have moving parts, they are slower and can wear out over time compared to Solid State
Drives (SSDs), which have no moving components. However, HDDs remain popular because
they offer large storage capacity at a lower cost.

Features of Hard Disk Drive (HDD)


 Large Storage Capacity: HDDs can store large amounts of data, ranging from a few
gigabytes (GB) to several terabytes (TB).
 Cost-Effective: Generally cheaper than SSDs, making them an affordable option for large
data storage.
 Size: Typically larger and heavier than SSDs.
 Performance: Slower than SSDs due to mechanical parts.
 Mechanical Parts: Due to its moving parts, HDDs can be less durable than SSDs.
Advantages of HDD
 Cost-Effective: HDD is also cheaper per gigabyte comparing to SSD which is good for
cost effective storage of large amounts of data.
 High Storage Capacity: HDDs are available in higher capacities than that of Floppy disks
are available making them ideal for application by people who require large storage
facilities such as multimedia.
 Availability: HDD has a relatively long history of usage and that is why it is widely
supported by the majority of devices.
Disadvantages of HDD
 Slower Speed: Due to the mechanical design of the actuator, have relatively low I/O data
rates in comparison to SSDs.
 More Fragile: As compared to SSDs, HDDs have higher chances of getting damaged due
to physical shocks or drops this is because they have moving parts.
 Higher Power Consumption: As it is a magnetic disk that continues to spin platters,
HDDs have higher power consumption and hence are less energy efficient particularly for
portable devices.

What is Solid State Drive(SSD)?


SSDs, on the other hand, use flash memory to store data instead of a spinning disk. SSDs have
no moving parts, making them much faster, more durable, and less susceptible to mechanical
failure than HDDs.

How do SSD work?

5|Page
LECTURE NOTES

A Solid State Drive (SSD) stores and retrieves data using flash memory instead of moving parts,
making it much faster and more durable than a traditional Hard Disk Drive (HDD).

SSDs use NAND flash memory chips to store data. When you save a file, electrical charges are
used to store information in tiny memory cells inside these chips. Each cell retains data even
when the power is turned off, allowing the SSD to keep your files permanently. Since SSDs have
no spinning disks or moving read/write heads like HDDs, they can access data almost instantly.

When you open a file or program, the SSD's controller quickly finds the required data and sends
it to the computer. Because SSDs rely on electronic circuits rather than mechanical parts, they
operate silently, use less power, and are more resistant to damage from drops or shocks. Their
speed significantly improves computer performance, making tasks like booting up, loading
applications, and transferring files much faster compared to HDDs.

Features of Solid State Drive (SSD)


 Fast Performance: SSDs offer much faster data access and transfer speeds than HDDs.
 Compact Size: SSDs are smaller and lighter than HDDs, making them an ideal option for
use in portable devices such as laptops and tablets.
 Lower Power Consumption: SSDs consume less power than HDDs, making them more
energy-efficient.
 Higher Cost: SSDs are generally more expensive than HDDs, making them a less cost-
effective option for storing large amounts of data.
 No Mechanical Parts: SSDs have no moving parts, making them more durable and less
susceptible to mechanical failure than HDDs.
Advantages of SSD
 Faster Performance: They are also significantly faster than their mechanical counterparts,
this in terms of booting up, transmitting files as well as improving on the general
performance of any device.
 Durability: Since there is no moving parts, there is low possibility of the SSDDs getting
damaged physically and as result are recommendable for use in laptops and other
portable devices.
 Lower Power Consumption: Further, SSDs are less power hungry that AT’s, which is
important in increasing battery back-up time in laptops and decreasing power
consumption in desktops.
Disadvantages of SSD
 Higher Cost: SSDs are still costlier than the HDD per unit of capacity, although the he is
reducing every now and then.
 Limited Storage Capacity: While today SSDs exist in larger capacities it should be noted
that when it comes to higher storage capacities SSDs are commonly costlier than the
HDDs.

6|Page
LECTURE NOTES

2.3. Organization of I/O Functions


I/O operations can be organized in various ways to balance efficiency, CPU utilization, and
complexity.
Types/Methods
 Polling (Programmed I/O): Polling is a technique where the CPU or a controlling
program repeatedly checks the status of an input/output (I/O) device at regular intervals
to see if it's ready for an operation.
 Interrupts: Device signals CPU when ready, allowing CPU to handle other tasks.

Example: A printer interrupts the CPU when a page is done printing.


Advantages: CPU efficient; supports multitasking.
Disadvantages: Overhead from interrupt service routines (ISRs); priority management needed.
Use Cases: Keyboard input in OS, where events are sporadic.

 DMA (Direct Memory Access): A DMA controller transfers data directly between device
and memory, bypassing the CPU. We can experiment this from copying large files from
disk to memory without CPU intervention. It can bring high throughput for bulk
transfers; and it equally frees the CPU entirely. Some drawbacks may be that , it requires
dedicated hardware, it is equally a potential bus contention system. A use case is video
streaming or network packet transfers in high-performance servers.

2.4. I/O Buffering Techniques


Buffering is a process in which the data is stored in a buffer or cache, which makes this stored
data more accessible than the original source. Buffer is an area in memory that is used to hold the
data that is being transmitted from one place to another and store the data temporarily. There are
a number of data storage devices that are used in a system, like Hard Disks, network devices, pen
drives, etc. So, there might be some waiting time faced by the processes or applications that are
attempting to access that data from the storage devices. This problem is mainly caused when the
devices from where device is slow or have low latency. The mitigation to this problem is
significantly solved using Buffering, as in this process the buffer acts as an intermediate between
the storage device and the processes/applications. In this process, the data is already transferred
to the Buffer so the data retrieval can be done from it which significantly reduces the waiting
time and hence improves the performance of the system.
Types of Buffering in OS
There are mainly three types of Buffering that are used in the operating system;
 Single Buffering
 Double Buffering
 Circular Buffering

 Single Buffering

7|Page
LECTURE NOTES

This is the simplest type of Buffering where only one system buffer is allocated by the Operating
System for the system to work with. The producer(I/O device) produces only one block of data in
the buffer for the consumer to receive. After one complete transaction of one block of data, the
buffer memory again produces the buffer data.

 Double Buffering
This is an upgrade over Single Buffering as instead of using one buffer data here two are used.
The working of this is similar to the previous one, the difference is that the data is first moved to
the first buffer then it is moved to the second buffer. Then retrieved by the consumer end. Here
on one hand the data is inserted into one buffer while the data in the other buffer is processed
into the other one.

 Circular Buffering
Double Buffering is upgraded to this, in this process more than two buffers are used. The
mechanism which was used earlier is a bit enhanced here, where one buffer is used to insert the

8|Page
LECTURE NOTES

data while the next one of it used to process the data that was earlier inserted. This chain of
processing is done until the last buffer in the queue and then the data is retrieved from the last
buffer by the consumer. This mechanism is used where we need faster data transfers and more
bulky data is transferred.

Function of Buffering in OS
Synchronization: This process increases the synchronization of different devices that are
connected, so the system's performance also improves.
Smoothening: The input and output devices have different operating speeds and Buffer data
block sizes, this process encapsulates the difference and ensures a smooth operation.

Efficient Usage: Using this processing technique the system overhead and the inefficient usage
of the system resources.

Advantages of Buffering

9|Page
LECTURE NOTES

 Buffering significantly reduces the waiting time for a process or application to access a
device in the system
 Smoothens the I/O operations between the different devices that are connected to the
system.
 Using Buffer number of calls needed for carrying out an operation, so it increases the
overall performance of the system.
 Buffering helps cut down on the number of I/O operations that are needed to access the
desired data.
Disadvantages of Buffering
 Buffers/Temporary memory that is used to assign data while transferring takes up a lot of
memory in a long process.
 Most of the time the exact size of the data going to be transferred is unpredictable so
more memory is assigned for every data and most of the time the extra space goes
wasted.
 Due to unpredictability sometimes more data is stored on the Buffer than it can store
which leads to Buffer Overflow and data corruption.
 In some situations, Buffers can result in a delay between the read and write of the data in
the memory and the processing of the data.

2.5. Disk Scheduling Algorithms


Disk scheduling optimizes the order of servicing read/write requests to minimize head movement
(seek time) on block devices like HDDs. (Less relevant for SSDs due to no mechanical parts.)
Key Concepts
///
RAID (Redundant Arrays of Independent Disks)
RAID is a technique that combines multiple hard drives or SSDs into a single system to improve
performance, data safety or both. If one drive fails, data can still be recovered from the others.
In RAID (Redundant Array of Independent Disks), data is not stored on just one hard drive but is
distributed across multiple drives.
 The data is split into small blocks (like dividing a file into chunks). These blocks are
written across multiple drives in parallel.
 Mirroring (RAID 1): Exact copy of data is kept on another drive.
 Parity (RAID 5, RAID 6): A calculated value (parity block) is stored to allow data
recovery in case of failure.
 Fault Tolerance: If one drive fails, RAID uses the redundant data (mirror or parity) to
reconstruct missing data.
What is parity? Parity check?
This improves performance by allowing multiple drives to read/write data simultaneously.

What is a RAID Controller?

10 | P a g e
LECTURE NOTES

A RAID controller manages multiple hard drives, making them work together as one system. It
helps improve speed and adds data protection by handling drive failures. Think of it as a smart
manager that boosts performance and keeps your data safe.

Types of RAID Controller


There are three types of RAID controller:

1. Hardware-Based:

Uses a dedicated physical controller to manage hard drives. Offers high speed and reliability.
Can work independently from the computer's processor. Often built into the motherboard or as a
separate card. Think of it as a captain managing the drives smoothly.
2. Software-Based:
Uses the computer’s processor and memory to manage RAID. No special hardware needed.
Cost-effective, but may reduce overall system performance. Slower than hardware RAID. Acts
like a helpful assistant, but shares the load with other tasks.
3. Firmware-Based (Fake RAID):
Built into the computer's BIOS/firmware and works during boot-up. Needs a driver after the OS
loads. Cheaper than hardware RAID, but still uses CPU resources. Also known as hybrid RAID
or fake RAID. A startup helper that hands over the job to software once the system runs.

Types of RAID
1. RAID-0 (Stripping)

11 | P a g e
LECTURE NOTES

RAID-0 improves system performance by splitting data into smaller "blocks" and spreading
them across multiple disks. This process is called "striping." It enhances data access speed by
enabling parallel read/write operations but provides no redundancy or fault tolerance.

A set of blocks distributed across the disks forms a "stripe." For instance, "0, 1, 2, 3" is one
stripe.
Instead of placing just one block into a disk at a time, we can work with two (or more) blocks
placed into a disk before moving on to the next one.
Evaluation:

 Reliability: 0, There is no duplication of data. Hence, a block once lost cannot be


recovered.
 Capacity: N∗B, The entire space is being used to store data. Since there is no
duplication, N disks each having B blocks are fully utilized.
Advantages:
 It is easy to implement.
 It utilizes the storage capacity in a better way.
Disadvantages:
 A single drive loss can result in the complete failure of the system.
 It's not a good choice for a critical system.

2. RAID-1 (Mirroring)
12 | P a g e
LECTURE NOTES

RAID-1 enhances reliability by creating an identical copy (mirror) of each data block on separate
disks. This ensures that even if one disk fails, the data remains accessible from its duplicate.
While this configuration is highly reliable, it requires significant storage overhead.

Mirroring: Each block of data is written to two (or more) disks. For example:
 Block 0 is stored on Disk 0 and its duplicate on Disk 1.
 Block 1 is stored on Disk 2 and its duplicate on Disk 3.
Mirroring Level 2: In the figure, "mirroring level 2" indicates that there are two copies of each
block, distributed across different disks. RAID 0 was unable to tolerate any disk failure. But
RAID 1 is capable of reliability.
Evaluation: Assume a RAID system with mirroring level 2.
 Reliability: 1 to N/2
1 to N/2, If we are lucky enough and disks 0 and 2 fail, then this can be handled as the blocks of
these disks have duplicates on disks 1 and 3. So, in the best case, N/2 disk failures can be
handled.
 Capacity: (N*B)/ 2, Only half the space is being used to store data. The other half is just
a mirror of the already stored data.
Advantages:
 It covers complete redundancy.
 It can increase data security and speed.
Disadvantages:
 It is highly expensive.
 Storage capacity is less.

3. RAID-2 (Bit-Level Stripping with Dedicated Parity)


13 | P a g e
LECTURE NOTES

RAID-2 is a specialized RAID level that uses bit-level striping combined with error correction
using Hamming Code. In this configuration, data is distributed at the bit level across multiple
drives and a dedicated parity drive is used for error detection and correction. While it offers
strong fault tolerance, its complexity and cost make it rarely used in practice.

Advantages:
 In case of Error Correction, it uses hamming code.
 It Uses one designated drive to store parity.
Disadvantages:

 It has a complex structure and high cost due to extra drive.


 It requires an extra drive for error detection.
4. RAID-3 (Byte-Level Stripping with Dedicated Parity)
RAID-3 enhances fault tolerance by employing byte-level striping across multiple drives and
storing parity information on a dedicated parity drive. The dedicated parity drive allows for the
reconstruction of lost data if a single drive fails. This configuration is suitable for workloads
requiring high throughput for sequential data but is less efficient for random I/O operations.

Here Disk 3 contains the Parity bits for Disk 0, Disk 1 and Disk 2. If data loss occurs, we can
construct it with Disk 3.
Evaluation:
 Reliability: RAID-3 can tolerate the failure of one disk. The lost data can be
reconstructed using the parity drive and the remaining data drives.
 Capacity: Usable Capacity =( N – 1 ) × B =(N−1)× B ,where N is the total number of
drives and B is the number of blocks per drive. The capacity of one drive is reserved for
storing parity information.

14 | P a g e
LECTURE NOTES

Advantages:
 Data can be transferred in bulk.
 Data can be accessed in parallel.
Disadvantages:

 It requires an additional drive for parity.


 In the case of small-size files, it performs slowly.
What is the difference between RAID 2 and RAID 3.

5. RAID-4 (Block-Level Stripping with Dedicated Parity)


RAID-4 introduces block-level striping across multiple disks, combined with a dedicated parity
disk to provide fault tolerance. Data is written in blocks and a separate disk stores parity
information calculated using the XOR function. This setup allows for data recovery in case of a
single disk failure, making RAID-4 more reliable than RAID-0 but less efficient in write-
intensive scenarios due to reliance on a dedicated parity disk.

In the figure, we can observe one column (disk) dedicated to parity.


Parity is calculated using a simple XOR function. If the data bits are 0,0,0,1 the parity bit is
XOR(0,0,0,1) = 1. If the data bits are 0,1,1,0 the parity bit is XOR(0,1,1,0) = 0. A simple
approach is that an even number of ones results in parity 0 and an odd number of ones results in
parity 1.

15 | P a g e
LECTURE NOTES

Assume that in the above figure, C3 is lost due to some disk failure. Then, we can recompute the
data bit stored in C3 by looking at the values of all the other columns and the parity bit. This
allows us to recover lost data.
Evaluation:
 Reliability: 1, RAID-4 allows recovery of at most 1 disk failure (because of the way

Capacity: ( N – 1 ) ∗ B (N−1)∗B, One disk in the system is reserved for storing the parity.
parity works). If more than one disk fails, there is no way to recover the data.

Hence,

( N – 1 ) (N−1) disks are made available for data storage, each disk having B blocks.
Advantages: It helps in reconstructing the data if at most one data is lost.

Disadvantages: It can't help reconstructing data when more than one is lost.

6. RAID-5 (Block-Level Stripping with Distributed Parity)


RAID-5 builds on RAID-4 by distributing parity information across all disks instead of storing it
on a dedicated parity drive. This distributed parity significantly improves write performance,
especially for random write operations, while maintaining fault tolerance for single disk failures.
RAID-5 is one of the most commonly used RAID configurations due to its balance between
reliability, performance and storage efficiency.

 Block-Level Striping: Data is divided into blocks and striped across all drives in the
array.
 Distributed Parity: Parity bits, calculated using the XOR function, are distributed across
all drives in a rotating pattern.
Example:

Disk 0: Data (D1, D2), Parity (P1)


Disk 1: Data (D3, D4), Parity (P2)

16 | P a g e
LECTURE NOTES

Disk 2: Data (D5, D6), Parity (P3)


Data Recovery: In case of a single disk failure, the missing data can be reconstructed by XOR-
ing the remaining data blocks and parity information.
Evaluation:
 Reliability: 1, RAID-5 allows recovery of at most 1 disk failure (because of the way
parity works). If more than one disk fails, there is no way to recover the data. This is

Capacity: ( N – 1 ) ∗ B (N−1)∗B, Overall, space equivalent to one disk is utilized in storing the
identical to RAID-4.

parity. Hence, ( N – 1 ) (N−1) disks are made available for data storage, each disk having B
blocks.
Advantages:
 Data can be reconstructed using parity bits.
 It makes the performance better.
Disadvantages:
 Its technology is complex and extra space is required.
 If both discs get damaged, data will be lost forever.

7. RAID-6 (Block-Level Stripping with two Parity Bits)


RAID-6 is an advanced version of RAID-5 that provides enhanced fault tolerance by introducing
double distributed parity. This allows RAID-6 to recover from the failure of up to two disks
simultaneously, making it more reliable for critical systems with larger arrays. However, the
added parity calculations can impact write performance.

 Block-Level Striping: Data is divided into blocks and striped across all disks in the
array.

 Double Distributed Parity: Two sets of parity information are calculated for every block
and distributed across all disks in the array in a rotating pattern.

17 | P a g e
LECTURE NOTES

Example:

Disk 0: Data (D1, D2), Parity (P1)


Disk 1: Data (D3, D4), Parity (P2)
Disk 2: Data (D5, P1), Parity (P3)
Disk 3: Parity (P2, P3), Data (D6)
Data Recovery: If one or two disks fail, the missing data can be reconstructed using the
remaining data and parity information.

Evaluation:

 Reliability: RAID-6 can tolerate the simultaneous failure of two disks, providing greater
fault tolerance than RAID-5.
 Capacity: Usable Capacity = ( N – 2 ) × B (N−2) × B where N is the total number of
disks and B is the number of blocks per disk.
Advantages:
 Very high data Accessibility.
 Fast read data transactions.
Disadvantages:
 Due to double parity, it has slow write data transactions.
 Extra space is required.

CHAPTER THREE: FILE MANAGEMENT


3.1 Introduction to File Systems: From Interface to Implementation
File systems are a core component of operating systems (OS) that manage data storage, retrieval,
and organization on secondary storage devices like hard drives or SSDs. They provide an
abstraction layer between users/applications and physical storage, ensuring data persistence,
integrity, and efficient access. The journey from interface to implementation involves user-facing
APIs, logical structures, and low-level disk management.

18 | P a g e
LECTURE NOTES

Key Aspects of File management

Interface Layer: High-level operations exposed to users and programs (e.g., via system calls).
Logical Layer: Internal representations like files and directories.
Physical Layer: Actual data placement on storage media.

Advantages of Modern File Systems

 Enable data sharing and protection in multi-user environments.


 Optimize storage efficiency and access speed.
 Support large-scale data with features like virtualization.

Disadvantages of Modern File Systems

 Overhead from abstraction can introduce latency.


 Complexity increases vulnerability to corruption or security breaches.

Use Cases

In cloud storage (e.g., AWS S3), file systems handle distributed data across servers.
In mobile Operating systems like Android, they manage app data isolation.

3.2. File System Interfaces and Structures


File system interfaces provide standardized ways to interact with files, while structures define
how data is organized internally.

File System Interfaces


19 | P a g e
LECTURE NOTES

These are system calls or APIs for file operations:


 Open: Prepares a file for access, returning a file descriptor (handle).
Example: In Unix, open("[Link]", O_RDONLY) opens a file for reading. It establishes context
(e.g., mode, position), supports concurrency. A disadvantage maybe failure if the file doesn't
exist or permissions deny access. A use case maybe starting a text editor session.
 Read: Transfers data from file to memory.
Example: read(fd, buffer, size) reads 'size' bytes into 'buffer'. It enables efficiency for sequential
or random access. But may lead to blocking if data not is not ready. It may also lead to potential
buffer overflows if mismanaged. A use case is Loading image data in a viewer app.
 Write: Transfers data from memory to file.
Example: write(fd, buffer, size) appends or overwrites data. It Supports creation/modification;
atomic in some systems. It may have a drawback such as Risk of data loss on failure; slower on
non-SSD storage. An example of such is Saving user input in a document.
 Close: Releases resources associated with the file descriptor. We have close(fd) flushes
buffers and frees locks. It prevents resource leaks, ensures data persistence. It causes
premature close which may cause data loss if not flushed. An example here maybe
Ending a logging session in an application.

File System Structures

 Inodes (Index Nodes): Metadata structures storing file attributes (e.g., size, timestamps,
permissions) and pointers to data blocks. In ext4 (Linux), each file has an inode with
direct/indirect block pointers. Leads to efficient metadata access, supports sparse files.
What is a parse file?
A drawback maybe Fixed inode count can limit file creation. Applicable in Unix-like systems
for quick attribute lookups.
 Directories: Special files containing mappings from names to inodes. A directory entry
(dirent) with filename and inode number. It enables hierarchical organization but leads to
directory fragmentation over time. Applications maybe File explorers like Windows
Explorer.

3.3. Organization of Files and Directories


File organization determines how data blocks are linked, while directory organization structures
the namespace.
File Organization Types
We have ;
- Sequential (Contiguous): Data stored in consecutive blocks.
Example: A 10KB file occupies blocks 100-109.
Advantages: Fast sequential access; simple implementation.
Disadvantages: Fragmentation; inefficient for growing files.

20 | P a g e
LECTURE NOTES

- Linked: Each block points to the next (linked list).


Example: Block 100 points to 150, which points to 200.
Advantages: No external fragmentation; easy to grow.
Disadvantages: Slow random access (traverse list); overhead per block.
Use Cases: FAT file systems for small files.

- Indexed: An index block holds pointers to data blocks.


Example: Inode with array of block addresses.
Advantages: Fast random access; supports large files via multi-level indexing.
Disadvantages: Extra space for index; complex for small files.
Use Cases: Databases requiring quick jumps (e.g., video editing).

Directory Organization Types

 Single-Level: All files in are in one flat directory. The early MS-DOS with all files at the
root directory. It provies fast and efficient lookup. But equally leads to Name collisions,
difficulty in multiple file management. Embedded systems use this type especially when
they have few files.
 Hierarchical (Tree-Structured): Nested directories. A hierarchical tree structure
arranges data in a tree-like format where each node has parent and child nodes, creating a
hierarchy. Hierarchical trees provide a clear and organized way to represent relationships
between different elements of data Example: /home/user/docs/[Link] in Unix. It can
facilitate Logical grouping and equally scalability.
What is scalability?
The hierarchical organization may lead to longer path resolutions and deep nesting issues.
The operating systems we use today like Windows use this for user data organization.

3.4. Secondary Storage Management


This techniques involves allocating space for files and managing free space on disks. We have
 Contiguous Allocation: Assigns consecutive blocks to a file.

Read on contiguous allocation

 Linked Allocation:
In linked allocation, file blocks are not stored continuously in memory. Instead, each file is
represented as a linked list of disk blocks, where each block contains a pointer to the next block.
This allows the blocks to be scattered across the disk, eliminating the need for contiguous
memory allocation. Each block has a pointer to the next; no contiguous requirement. This is
Flexible and offers no fragmentation waste.
A draw back maybe Pointer overhead and reliability issues if link breaks.

21 | P a g e
LECTURE NOTES

It is used in media such as Floppy disks or low-end storage.

 Indexed Allocation: Central index points to all blocks.


Example: Unix inodes with direct, single-indirect, double-indirect pointers.
Advantages: Efficient for random access; supports large files.
Disadvantages: Index block overhead; multi-level indirection slows access.
Use Cases: High-performance file systems like NTFS.

Free Space Management

Bitmaps (Bit Vectors): In disk free space management, the bitmap or bit vector approach is
commonly used to track the allocation status of disk blocks. In this method, each block is
represented by 1 bit. A bit value of 0 indicates that the block is free. A bit value of 1 indicates
that the block is allocated. For 1TB disk with 4KB blocks, bitmap is ~32MB.
Advantages maybe Compactness, fast to find free blocks through bit operations.
Drawbacks maybe large bitmaps for big disks scanning for contiguous space is slow.
Very relatable in ext2/3 file systems.

22 | P a g e
LECTURE NOTES

Linked Lists: In this approach, Free blocks are linked together in a list. Each free block stores
the address of the next free block. The list is maintained dynamically as blocks are allocated and
freed.

The Free list head points to first free block. They have no extra space; easy to allocate/deallocate.
They may be Slow to traverse for large free spaces, fragmentation.
Applicable in simple Operating system or memory management.

Boundary Tags
In this approach, Each block contains a boundary tag indicating its size and whether it is free or
occupied. Adjacent free blocks are merged during deallocation to reduce fragmentation. Useful
in memory management systems. Simplifies coalescing of adjacent free blocks. Despite that ,
Slight overhead in storing tag information. It is more complex than bitmap or linked list.

23 | P a g e
LECTURE NOTES

Free List
In this approach, The free blocks are maintained in a list (array or linked list). Each entry in the
free list points directly to a free block on disk.

It offers fast allocation as free blocks are known upfront. Easy to traverse and maintain.
As cons, Extra memory is needed to store the list. May suffer from fragmentation over time
3.5. Specific File Systems: FAT and NTFS
FAT (File Allocation Table) and NTFS (New Technology File System) are two file systems used
by Windows, each with distinct features, advantages, and limitations.
FAT is a simple file system developed by Microsoft in the 1970s, primarily for small disks and
simple folder structures. The most common variant today is FAT32. FAT32 is widely supported
across various operating systems and devices, making it ideal for removable storage like USB
drives and memory cards.

24 | P a g e
LECTURE NOTES

FAT32 stands for File Allocation Table. FAT32 is an extension of previous file systems in which
the data is stored in chunks of 32 bits. FAT32 is an upgraded version of FAT16 designed to
overcome the limitations of FAT16 and add support for larger media. FAT32 was used in older
versions of operating systems like Windows 95 up until Windows XP.
FAT32 is the original file system for the Windows operating system, having been developed in
the 1970s. It was mainly made for floppy drives with capacities less than 500 K. Each of the
three FAT file systems—FAT12, FAT16, and FAT32—has a different file size and disc layout.
Initially, MS-DOS used the FAT file system, with a maximum hard drive size of 32 MB and
sectors partitioned into 512 K. It frequently appears in removable discs and storage devices. A
FAT32 drive's maximum file size is limited to 4 GB, while the size of a FAT32 partition cannot
exceed 8 TB. The lack of security offered by FAT32 is its primary drawback. File access
protection is absent from FAT16, the prior version of the file system, and thus suffers from
internal fragmentation.

25 | P a g e
LECTURE NOTES

Some features of Features of FAT32


Legacy Compatibility: FAT32 has been around because the early days of computing and is
broadly supported throughout diverse operating system and devices. It is commonly used for
USB flash drives, SD playing cards, and different removable media because of its huge
compatibility.
Simple Structure: FAT32 has a tremendously easy document system structure, along with a File
Allocation Table (FAT) that keeps track of report allocation at the disk. This simplicity makes it
easy to implement and understand however additionally limits its abilities compared to extra
cutting-edge document systems.
No Journaling: FAT32 does no longer help journaling, a function determined in extra superior
record systems like NTFS. Journaling allows preserve the consistency of the record in case of
sudden shutdowns or crashes by way of preserving track of changes earlier than they're devoted
to the disk.
Limited Support for Long Filenames: While FAT32 supports lengthy filenames (up to 255
characters), it uses a backward-compatible technique referred to as 8.3 report naming conference,
which restricts filenames to eight characters followed by using a three-individual record
extension.

Management of FAT32 File System Disk Space


The control data is stored independently of the file system in the linked allocation that the FAT32
file system uses. Every disc block in an array has an element in the file allocation table of that
disc. A file is assigned a disc block, and the associated FAT element retains the next disc block
address. Because of the linked allocation, the disc block and its FAT component together
comprise a unit that shares the same data as the disc block. The address of the first disc block is
contained in a file's directory entry, while the address of the second disc block is contained in the
FAT element for that disc block. The final disc block contains the unique code that denotes the
file's end.
Advantages of FAT32
 FAT32 efficiently works under partitions of 200 MB.
 FAT32 provides compatibility with different operating systems.
 FAT32 is frequently used as a primary partition on multiboot systems.
 Disc partitions of up to 2 TB can be made using FAT32.
Partitions formatted as FAT16 are limited to 2GB in size.
 FAT32 uses much less disc space for large partitions because the minimum cluster size
for partitions under 8GB is still a modest 4KB. Because it is compatible with several
operating systems, it is frequently used as the primary partition on multi-boot systems.
Disadvantages of FAT32
The partitions in FAT32 of size over 200 MB can degrade the performance.
 FAT32 is insecure because of the lack of encryption.
 FAT32 is susceptible to fragmentation.

26 | P a g e
LECTURE NOTES

NTFS
NTFS stands for New Technology File System. First introduced in 1993, it is used in newer
versions of operating systems such as Windows NT and 2000 and later versions of Windows.
NTFS is a more robust, high-performance logging file system with multi-user access control,
ACLs, and many other things that make it appropriate to work with an Operating System that has
protection. NTFS includes characteristics such as data recovery, multi-streaming, fault tolerance,
security, extended file size, and file systems, UNICODE names. exFAT is used where NTFS is
not feasible, due to its data-structure overhead, but a greater file-size limit than the standard
FAT32 file system is needed.

Features of NTFS
Advanced Features: NTFS is a feature-rich file system designed to meet the needs of modern
computing environments. It supports features including record compression, encryption, disk
quotas, symbolic links, and document system journaling, imparting greater flexibility and
capability compared to FAT32.
Dynamic Disk Support: NTFS supports dynamic disks, which allows for superior disk
management capabilities consisting of software RAID (Redundant Array of Independent Disks).
Sparse File Support: Sparse documents are used in programs along with digital machines and
database systems to effectively allocate garage space for facts this is in general empty.
Transaction Support: NTFS helps transactions, permitting a couple of report machine
operations to be grouped together as a single atomic transaction. This ensures statistics integrity
and consistency, specially in situations where more than one operations want to be done together
(e.G., database transactions).
Improved Security: NTFS presents sturdy security features, which includes file and folder
permissions, get right of entry to access control lists (ACLs), and encryption.

Management of NTFS File System Disk Space


Various disc sector size have no dependency on the NTFS file system. The cluster idea, which is
a collection of adjacent sectors, is used to allocate disc space a cluster may have up to 2n parts. A
bitmap file is used to represent the allocated and unoccupied clusters in a volume, which is a
logical partition on a disc. Unusable clusters are also tracked by a file called a bad cluster file.
You can use a volume set to surpass the partition's 32-volume maximum.
The NTFS volume contains the boot sector, the master file table (MFT), and additional user and
system data. Similar to a FAT table, the master file table (MFT) contains all of the data regarding
the files and directories on the drive. Because each volume contains a boot sector, it can all be
booted.

27 | P a g e
LECTURE NOTES

Advantages of NTFS

NTFS is highly secure because it prevents unauthorized access to file contents by enforcing
Encryption File System(EFS).
NTFS performs well even in the partitions of size over 400 MB.
NTFS is less susceptible to fragmentation.
NTFS offers faster processing and is more stable than FAT32. File attributes can also be
classified as resident or non-resident. While the non-resident features are maintained outside of
MFT, the resident characteristics are retained within MFT. When Windows starts, the MFT is
loaded and all properties are retained if the file is less than 1KB.
Physical and logical disc issues may be automatically fixed by the NTFS file system. The sector
is checked before every read and write operation. Any mistakes that arise while reading will be
reported. If an issue arises during writing the data, it will choose the appropriate sector to write
the data in. Additionally, it will highlight the damaged area so you don't use it again.
Disadvantages of NTFS
NTFS is not extensively supported.
Performance in the NTFS file system degrades under partitions of 400 MB.
It takes a lot of extra space for the NTFS file system to function. "Space overhead" is the term
for the data storage used by the file system itself; this data storage is not meant to hold other
kinds of data. Therefore, if you format a drive that uses the NTFS file system, you will lose some
storage capacity.
One of the main problems with the NTFS file system is that it is incompatible. Windows 2000
and later operating system versions are compatible with it. Windows versions prior to this one
are not compatible.
File naming is subject to several limitations. The maximum character count for the directory and
file names is 255. The system does not distinguish between lowercase and uppercase letters, even
though file names may contain capital letters.
Because of the required space overhead, a floppy disc cannot be formatted using the NTFS file
system. Floppy disc drives are widely used in older Windows-based computers.
Without the aid of third-party software, Mac computers are unable to write data on NTFS
formatted storage.

28 | P a g e
LECTURE NOTES

3.6. File Protection and Security Mechanisms


File protection in an operating system is the process of securing files from unauthorized access,
alteration, or deletion. It is critical for data security and ensures that sensitive information
remains confidential and secure. Operating systems provide various mechanisms and techniques
such as file permissions, encryption, access control lists, auditing, and physical file security to
protect files. Proper file protection involves user authentication, authorization, access control,
encryption, and auditing.
Types of File protection
File Permissions : File permissions are a basic form of file protection that controls access to files
by setting permissions for users and groups. File permissions allow the system administrator to
assign specific access rights to users and groups, which can include read, write, and execute
privileges. These access rights can be assigned at the file or directory level, allowing users and
groups to access specific files or directories as needed. File permissions can be modified by the
system administrator at any time to adjust access privileges, which helps to prevent unauthorized
access.
Encryption: Encryption is the process of converting plain text into ciphertext to protect files
from unauthorized access. Encrypted files can only be accessed by authorized users who have
the correct encryption key to decrypt them. Encryption is widely used to secure sensitive data
such as financial information, personal data, and other confidential information. In an operating
system, encryption can be applied to individual files or entire directories, providing an extra
layer of protection against unauthorized access.
Access Control Lists (ACLs) : Access control lists (ACLs) are lists of permissions attached to
files and directories that define which users or groups have access to them and what actions they
can perform on them. ACLs can be more granular than file permissions, allowing the system
administrator to specify exactly which users or groups can access specific files or directories.
ACLs can also be used to grant or deny specific permissions, such as read, write, or execute
privileges, to individual users or groups.
Auditing and Logging: Auditing and logging are mechanisms used to track and monitor file
access, changes, and deletions. It involves creating a record of all file access and changes,
including who accessed the file, what actions were performed, and when they were performed.
Auditing and logging can help to detect and prevent unauthorized access and can also provide an
audit trail for compliance purposes.
Physical File Security: Physical file security involves protecting files from physical damage or
theft. It includes measures such as file storage and access control, backup and recovery, and
physical security best practices. Physical file security is essential for ensuring the integrity and
availability of critical data, as well as compliance with regulatory requirements.

29 | P a g e

You might also like